JSON Schema Generator

  • Draft 2020-12
  • Merged arrays
  • Instant

A draft 2020-12 schema inferred from a sample, ready to refine.

Input
JSON Schema

Paste input on the left to see json schema.

Everything runs in your browser — nothing is uploaded.

About json schema

Generating a JSON Schema from a sample produces a draft 2020-12 document describing the data's types and required keys. JSONic merges array element shapes into one items schema and distinguishes integer from number. Treat it as a starting point and relax what the sample could not tell it.

Paste a representative JSON document to get a draft 2020-12 schema for it: object properties with their types, arrays typed from their merged element shape, and integer distinguished from number where the sample allows it. Use it as a starting point for contract tests and request validation, then relax the required list and widen types where the sample was incomplete.

Questions

Why is every key marked required?

The sample is the only evidence available, so every key present is marked required. Remove the ones that are genuinely optional in your API — a generated schema that is too strict is at least easy to loosen.

How are arrays typed?

Element shapes are merged into a single items schema, so an array of similar-but-not-identical objects yields one usable schema rather than a positional tuple.

Which draft is emitted?

Draft 2020-12, declared through the $schema keyword. Most current validators — Ajv, python-jsonschema, everit — support it.