JSON Schema

What Is the JSON Schema Generator?

Generate JSON Schema definitions from sample JSON data. Create validation schemas automatically for API documentation and data validation.

Why Use This Tool?

JSON Schema defines the structure, types, and constraints of JSON data. Writing schemas manually is tedious and error-prone. This tool analyzes sample JSON and generates a complete schema definition automatically.

How to Use This JSON Schema Generator

  1. Paste your JSON — Copy a sample JSON object or array and paste it into the input field. The more representative your sample, the better the generated schema.
  2. Generate the schema — The schema updates as you type, inferring types and structure from your JSON (every key is marked required; arrays are typed from their first item).
  3. Review and refine — Check the generated schema for accuracy. Add descriptions, adjust types, or mark fields as optional as needed.
  4. Copy and use — Copy the JSON Schema and integrate it into your API validation, form generation, or documentation pipeline.

Worked example: does the sample pass its own schema?

A generated schema should at least accept the data it was made from. The generator now merges every object in an array and every value seen for a key: a key is required only when every object has it, a field seen as null and as text becomes a union, whole and decimal numbers become number, and arrays of mixed values get a union item type. On October 13, 2026 we validated each sample against its own schema with Ajv 8.17.1, in both drafts the tool now offers:

SampleBefore (v211)Now (2020-12 and draft-07)
The default sample (one object, nested address, tags array)passespasses
Array where the 2nd object lacks emailfailed: must have required property 'email'passes (email optional, id required)
Field that is null, then a date stringfailed: must be nullpasses (["string","null"])
Prices 1, then 1.5failed: must be integerpasses (number)
Array ["a", 1, true, null]failed: must be stringpasses (union of the four types)
Nested profile present in some records onlyfailedpasses (profile optional, bio optional inside it)

We also fed it real configuration files: the 90 package.json files in one installed front-end toolchain (a node_modules folder). Each file's own schema accepted it 83 of 90 times before and 90 of 90 now; and when all of them were given as one array, the single merged schema accepted every file (90 of 90), where the old first-item schema accepted 1. In the page in Chromium, 10 of 10 sample and draft combinations passed Ajv.

Related tools

Frequently Asked Questions

Does it detect all data types?
It types strings, booleans, null, objects, arrays, integers and numbers, and merges what it sees across all records: optional keys stay out of required, fields that are sometimes null become unions such as ["string","null"], and a number field with any decimal becomes number. Formats, patterns and enums are not guessed.
Can I customize the generated schema?
The generated schema is a starting point. You can add constraints like minLength, maximum, pattern (regex), and enum values to make validation more specific.
What is JSON Schema used for?+
JSON Schema is a vocabulary for annotating and validating JSON documents. It's used for API request/response validation, form generation, configuration file validation, data documentation, and code generation. Think of it as a contract that describes what valid data looks like.
What JSON Schema draft should I use?+
Draft 2020-12 is the latest version and recommended for new projects. Draft 7 (draft-07) is still widely supported by validation libraries. Check your tooling's compatibility before choosing a draft version.
Can JSON Schema validate nested objects and arrays?+
Yes, JSON Schema fully supports nested structures. Use the properties keyword for nested objects and items for arrays. You can define schemas for each level of nesting.
Which JSON Schema draft does the generator target?+
Your choice: draft 2020-12 (default) or draft-07, set with the selector above the output. With Ajv, load ajv/dist/2020 for 2020-12; the default Ajv build reads draft-07.
Can the generator infer required versus optional fields from sample JSON?+
Yes, from several records. Paste an array of objects and a key is required only if every object has it; a key missing from some objects becomes optional. With a single object every key is required, because the generator has nothing to compare it with.

📖 Learn More

Related Article JSON Schema Validation: The Complete Guide →

Built by Derek Giordano · Part of Ultimate Design Tools

Privacy Policy · Terms of Service