JSON

JSON Schema Generator

Infers a draft JSON Schema from a sample document, including types, required keys and array item shapes.

Loading the tool…

Processing happens locally in your browser. What you paste or load is processed by this page and is not uploaded to a server. Nothing is stored unless you use a control that says it stores something, and you can clear anything this site has kept from the privacy page.

How to use this tool

  1. Paste a document that is representative of the data, not an edge case.
  2. Decide whether every key present in the sample should be marked required.
  3. Select Generate schema, then add descriptions, formats and constraints by hand.

What json schema generator does

Writing a JSON Schema by hand for a large response is tedious, and most of it is mechanical. Inferring a first draft from a real sample gets the structure right immediately and leaves you to add the parts a sample cannot tell you: descriptions, formats, value constraints and which optional fields are genuinely optional.

Treat the output as a starting point rather than a finished contract. A single sample cannot distinguish a field that is always present from one that happened to be present this time, and a null in the sample says nothing about whether null is permitted. Feed it several representative documents and reconcile the drafts before publishing a schema.

Frequently asked questions

No — treat it as a first draft. A sample cannot tell you which fields are genuinely optional, what value ranges are allowed, or what any field means. Add descriptions, formats and constraints before using it as a contract.

Draft 2020-12, declared in the $schema keyword. The output uses only widely supported keywords — type, properties, required, items and additionalProperties — so it works with older validators too.

It merges the observed item types into a union so the schema accepts every value in the sample. If that union looks wrong, the underlying data is probably inconsistent and worth fixing before the schema is.

Further reading