JSON Schema Generator
Infer a starting schema from a single example.
About this tool
Objects, arrays, strings, numbers, and booleans in that sample become schema nodes.
One sample cannot prove which fields are required in other documents. Treat the schema as a draft.
How to use it
- Open this page and provide the input it asks for.
- Set the options that are visible, then use Generate schema.
- Read the result in the panel. Copy it or download it when a file is offered. The input stays in this browser.
Limitations
- One sample cannot prove which fields are required in other documents. Treat the schema as a draft.
A draft schema inferred from a single sample
One value, walked once
One sample becomes a draft 2020-12 schema. The paste is parsed as JSON. The walker then builds a schema object and the page attaches the draft 2020-12 schema identifier before printing the result with a two-space indent. The page tells you the schema was inferred from this one sample and is not a complete schema. That warning is the point of the tool. The output is a starting document, not a contract you should publish without reading.
A null sample becomes a schema whose type is null. A boolean, a number, or a string becomes a schema whose type is that primitive. Nothing records the particular string as an enum. A single email-shaped string does not gain a format. An object becomes a schema with a property for every key that was present, and every one of those keys is listed as required. Keys that were absent from the sample are not mentioned. Additional properties are not forbidden, because the walker never writes that keyword. Extra keys would still validate against the generated schema.
Arrays remember only the first element
An array’s item schema is the schema of the first element. Later elements are ignored, so a mixed array of a string and a number produces an item schema for the string alone. An empty array produces an item schema that is an empty object, which constrains almost nothing. Nested objects are walked the same way, each level required only for the keys that appeared in the sample. A key whose value is null is typed as null, not as a union that also allows a string next time.
What you still have to write
Bounds, patterns, enums, dependent fields, and the choice between oneOf alternatives are not inferred. Two samples are not merged. If the next payload omits a key that happened to be present here, the generated required list will reject it. If the next payload uses a number where the sample used a string, the type will reject it. Run the validator when you want that check. Edit the generated document before you treat it as the shape of a whole API.
Privacy
Your input is processed in your browser and is not uploaded to UtilChain. File names, text, and results are not sent to analytics.

