JSON Schema Generator
Infer Draft 2020-12 or Draft 7 schemas from sample JSON values
Inferred types, properties, required keys, and array items will appear here.
About this tool
JSON Schema Generator infers a starter schema from a sample JSON value. It handles nested objects, arrays, integer versus number values, mixed arrays through anyOf, and nullable fields through a type union. For arrays of objects, field types and required status are inferred across every sample item. You can target Draft 2020-12 or Draft 7, require keys present in every sample or every observed key, disable required generation, add primitive examples, and optionally set additionalProperties to false. Inference cannot discover business constraints such as formats, ranges, patterns, uniqueness, or conditional rules, so review the result before using it as a contract.
Scenario Recipes
Bootstrap an API response contract from fixtures
Goal: Create a reviewable schema from several representative records
- Paste an array containing normal, optional, null, and nested field examples.
- Select the target draft and use the present-in-every-sample required rule.
- Generate the schema, then add explicit formats, ranges, patterns, and domain constraints before validation.
Result: A type-complete starter schema ready for contract review rather than blind production use.
Frequently Asked Questions
Which JSON Schema drafts can it generate?
The output can target JSON Schema Draft 2020-12 or Draft 7 through the corresponding $schema URI.
How are required fields inferred?
For object samples, you can require keys present in every sample, require every observed key, or omit required entirely.
How are null values represented?
A field observed as both a value and null receives a type union containing its inferred type and null.
What happens with mixed array values?
Different observed item types are represented with anyOf, while object items are merged across the available samples.
Does inference detect email, date, regex, or numeric limits?
No. Those are business constraints that need explicit review and should be added after type inference.
Is the sample JSON uploaded?
No. Parsing, recursive inference, and output formatting all run locally in the current browser.
Keep browsing