JSON Schema generator
About JSON Schema Generator
This JSON Schema generator creates a draft 2020-12 schema from sample JSON. Paste a document and it writes the types, properties, required keys and array items for you.
Switch to validate mode to check a JSON document against a schema you provide. Each violation is listed with its JSON Pointer path.
Use it to start an API contract, set up request validation, or document a data structure. Runs in your browser. Nothing is uploaded.
How it works
Draft 2020-12 output
Generated schemas include the $schema keyword for draft 2020-12, so validators know which dialect to use. Types are inferred as object, array, string, number, integer, boolean or null. Whole numbers become integer.
Required-property inference
In a single object, every key it has is marked required, because one example is the only evidence. In an array of objects, only keys present in every element are required. Trim the required list for fields you know are optional.
Arrays and nested objects
For arrays, the element schemas are merged into one items schema. If elements disagree on a type, the result lists both types. Nested objects get their own properties and required lists at every level.
Validate mode
Put your data in the first input and the schema in the second. The validator checks type, required, properties, items, enum and const, and lists every mismatch with its path, such as #/user/id.
Frequently asked questions
How do I generate a JSON Schema from JSON?
Paste a representative JSON sample with every field filled in. The generator outputs a draft 2020-12 schema right away. Then edit it by hand for optional fields, formats and constraints a sample cannot show.
Which JSON Schema version does it generate?
Draft 2020-12, the current specification. The output includes the matching $schema declaration.
Why are all properties marked required?
A single object gives no evidence that any key is optional, so every key it has is marked required. Remove optional fields from the required array yourself, or paste an array of samples so keys missing from some elements are left out.
Can one sample capture every case?
No. Use a sample with all fields populated, then add enums, formats and constraints by hand.
How do I validate data against a schema?
Switch to validate mode, put your data in the first input and the schema in the second. The tool tells you whether the data conforms and lists each mismatch by path.
Is my sample data uploaded?
No. Generation and validation both run in your browser.
Sources & last verified
We checked this tool's behavior and the claims on this page against the specifications below on . The tool runs in your browser, so the output you see is exactly what the engine produced.
Found a wrong result or an outdated claim? Report an error and we will check it again.