JSON Schema Generator
Infer a draft 2020-12 JSON Schema from a sample document, with format and enum detection.
Processing: This tool runs entirely in your browser. Your input and any file you open stay on your device — nothing is uploaded to a server.
How to use the json schema generator
- Paste a representative JSON document — the more complete the better.
- Choose whether present keys are required and whether formats are detected.
- Copy the schema and edit the fields the sample could not tell you about.
About this tool
Writing a JSON Schema by hand from an existing payload is tedious and error-prone, and most of it is mechanical: every value has a type, and the structure is already there in the sample. This generator does the mechanical part and leaves the judgement to you.
What it produces is a description of the document it was given, which is not the same thing as a specification. An optional field that happens to be present in the sample becomes required; a field that happens to be absent is not described at all. That gap is inherent to inferring from an example rather than a flaw in the inference, so the result is best read as a first draft to edit.
Arrays of objects are where a careless generator lies. If the first order has a note and the second does not, then note is optional — so the schemas for the items are merged and only keys present in every element are marked required. Integer and number are merged to number, since both describe the same JSON values and claiming integer would reject a legitimate 5.0.
Format detection is offered because a string that matches an email, a UUID or an ISO timestamp almost always means that thing. It is annotation rather than constraint: most validators treat `format` as advisory unless explicitly configured otherwise, so it documents intent without silently rejecting data.
Common uses
- Starting a schema for an API response you already have an example of.
- Documenting the shape of a config file for validation in CI.
- Checking what structure a third-party payload actually has.
Frequently asked questions
- Why are all my optional fields marked required?
- Because they were present in the sample, and one document cannot show which fields are optional. Turn the required option off, or delete the entries that should not be there.
- How are arrays of objects handled?
- Their schemas are merged into one, and only keys present in every element are marked required. A key on some elements but not others is described but left optional.
- Which draft does it generate?
- Draft 2020-12, the current one, declared in the $schema keyword. Most of what it emits — type, properties, required, items — is unchanged across recent drafts.
Related tools
JSON Schema Validator
Check a JSON document against a schema and get a JSON Pointer to every value that fails.
JSON Formatter
Format, validate and minify JSON with clear error messages that point at the exact position.
JSON Diff
Compare two JSON documents structurally, ignoring key order and formatting.
JSON ↔ YAML Converter
Convert JSON to YAML or YAML back to JSON, in either direction, with indent control.