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
- 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.
- 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).
- Review and refine — Check the generated schema for accuracy. Add descriptions, adjust types, or mark fields as optional as needed.
- 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:
| Sample | Before (v211) | Now (2020-12 and draft-07) |
|---|---|---|
| The default sample (one object, nested address, tags array) | passes | passes |
Array where the 2nd object lacks email | failed: must have required property 'email' | passes (email optional, id required) |
| Field that is null, then a date string | failed: must be null | passes (["string","null"]) |
| Prices 1, then 1.5 | failed: must be integer | passes (number) |
| Array ["a", 1, true, null] | failed: must be string | passes (union of the four types) |
| Nested profile present in some records only | failed | passes (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.
- Give it several records. Paste an array of real examples: the more variation it sees, the closer the schema is to your data. A single record still makes every key required.
- Whole numbers stay integer unless a decimal appears. JavaScript cannot tell 10 from 10.0, so a price that is whole in every sample is typed integer; include a decimal example or change it to number.
- It describes shape, not meaning. No formats, patterns, enums or ranges are guessed; add
format,minLength,enumormaximumyourself where they matter. - Pick the draft your validator reads. Draft 2020-12 needs Ajv's 2020 build (
ajv/dist/2020); draft-07 works with Ajv's default build and most older tools. The keywords used here mean the same in both.
Sources
Checked on .
Related tools
- After drafting a schema from a sample document, validate other documents against it with the JSON Schema Validator — same ajv 8 engine, full error reporting per instance path.
Frequently Asked Questions
Built by Derek Giordano · Part of Ultimate Design Tools