Skip to main content
QUIETLYTIC
Developer

JSON to JSON Schema

Infer a JSON Schema (2020-12) document from a JSON example.

Local · nothing leaves this browser Waiting for JSON
Esc Clear
JSON Schema (2020-12)

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

From the intelligence desk