JSON Schema Generator
Generate a JSON Schema (Draft 2020-12) from a sample JSON document. Smart format detection.
Quick answer: JSON Schema Generator: generate a JSON Schema (Draft 2020-12) from a sample JSON document. Smart format detection. Runs entirely in your browser, free, no signup.
Last updated
Good to know
A schema generated from a single example is a starting point, not a finished contract. Because the tool sees one document, it marks every property as required and pins each type exactly. That is usually too strict for real APIs, where fields come and go and some values are legitimately null. Expect to prune the required array and widen types before you ship the schema to production validation.
The format detection is genuinely useful: strings that look like ISO 8601 timestamps, email addresses, or URIs get the matching format keyword, which downstream validators such as Ajv can enforce. Draft 2020-12 is the output dialect, so it plays nicely with modern tooling, but note that some format checks are opt-in and must be enabled in your validator's configuration.
If your data varies across records, generate a schema from a few representative samples and merge them by taking the union of properties and the intersection of required keys. For editing the resulting document, pretty-printing it, or converting between formats, pair this with the JSON formatter. Reserve heavyweight schema-inference libraries for when you need enums, pattern constraints, or multi-file references.
Frequently asked questions
- Why is my schema too strict?
- We infer from a single example, so every field is required and types are exact. Loosen the schema by removing keys from the <code>required</code> array or using <code>type: ["string", "null"]</code> for nullable fields.
- Which draft is the output?
- JSON Schema Draft 2020-12, the latest stable version. It's compatible with all modern validators (Ajv, JSON Schema Validator, etc.).
- Will it detect emails, URLs and dates?
- Yes — string values matching email, date-time (ISO 8601) and URL patterns get the corresponding <code>format</code> annotation.
- Are my JSON files uploaded?
- No — inference runs entirely in your browser.
- How do I infer from multiple samples?
- Generate a schema from each sample, then merge by hand (or use a tool like <code>quicktype</code>) — taking the union of properties and the intersection of required keys gives a schema that fits all samples.