JSON to JSON Schema
Infer a JSON Schema (2020-12) document from a JSON example.
Paste JSON on the left.
How it works
JSON Schema is the shape description most tooling outside TypeScript actually reads — an OpenAPI spec, an ajv validator, a config file's own schema reference. This proposes one from an example the same way the TypeScript and Zod converters do: infer per field, merge across an array's items, mark a field required only where every item actually has it.
Draft 2020-12
The current draft, and the one new tooling targets. If a consumer expects an older draft — many still expect
draft-07's $schema value — swap the $schema URI; the type/
properties/required shape this produces is unchanged across drafts for everything this
tool infers.
No format keywords are guessed
A string that looks like a date or a UUID is still typed as {"type":"string"}, not
{"type":"string","format":"date"}. Inferring a format from one example that happens to match a
pattern is exactly the kind of confident wrong answer a single-document inference should not produce — add the
format keyword yourself once you know it is a rule, not a coincidence.
Example
{"id":1,"active":true} produces
{"type":"object","properties":{"id":{"type":"number"},"active":{"type":"boolean"}},"required":["id","active"]}
.
Frequently asked questions
Which JSON Schema draft does this target?
Draft 2020-12, the current one and what new tooling targets. The type/properties/required shape this produces is unchanged across recent drafts for everything this tool infers — swap the $schema URI if a consumer expects an older draft.
How is "required" decided?
A field is required only if every item in an array actually has it. A single object with no surrounding array has nothing to compare against, so every one of its fields is required by default.
Related tools
JSON to TypeScript
Infer a TypeScript interface from a JSON example, with optional fields worked out from an array.
LocalJSON to Zod Schema
Infer a runtime-checkable Zod schema from a JSON example.
LocalJSON Formatter & Validator
Format, validate and measure JSON, with errors located by line and column.
LocalJSON Schema Validator
Validate a JSON document against a JSON Schema and see exactly which rule failed, and where.
LocalCSV ⇄ JSON Converter
Convert CSV to a JSON array of objects, or back, with proper quoted-field parsing.
LocalJSONL Formatter & Validator
Validate JSON Lines file by line and convert it to a single JSON array.
Local