JSON Schema Generator
Infer a JSON Schema (draft 2020-12 or draft-07) from sample JSON
How to use
- Paste a sample JSON document (object or array).
- Optionally set a schema title.
- Pick the draft: 2020-12 (modern) or draft-07 (legacy tooling).
- Copy the schema, or validate sample data against it with the validator tool.
About this tool
A schema is only as honest as its sample. Instead of emitting required-everything schemas from a single example, this generator treats arrays as evidence: union of fields across elements decides optional/required, and nulls decide nullability. The result validates your real traffic, not just the happy-path sample.
Frequently asked questions
How are required fields inferred?
From your sample: fields present in every element of an array are required; fields missing anywhere become optional. Null values mark fields as nullable.
How is reusing handled for repeated shapes?
Identical nested object shapes are emitted once under $defs and referenced with $ref, keeping large schemas readable.
Which draft should I pick?
Use 2020-12 for modern tooling (it uses $defs). Choose draft-07 only when a downstream validator requires it (definitions-based).
Is my data uploaded anywhere?
No. Schema inference runs locally in your browser.