JSON Schema generator
Generate a JSON Schema from sample data — Draft 2020-12, with required-field inference.
Runs 100% in your browserHow to generate a JSON Schema
- Paste sample JSON. Any valid object or array. Arrays of objects produce the strongest schemas.
- Pick required-field policy. Strict marks every field as required; default only marks fields present in every record.
- Copy the schema. Click Copy to grab the Draft 2020-12 schema.
About JSON Schema inference
A small sample produces a usable, conservative schema — feed an array of representative records
for the strongest inference. The page collects the observed type per field (with integer vs
number distinguished), folds null values into a multi-type union, and emits
additionalProperties: false so unknown keys are rejected. Loosen that policy by
editing the output if your sample is not exhaustive.
Frequently asked questions
- A vocabulary that lets you describe and validate the shape of a JSON document — required fields, types, ranges, enums. Draft 2020-12 is the current version.
- The page walks your sample JSON, collects observed types per key, and emits the narrowest schema that accepts every record in the sample. Fields present in every record become required; others are optional.
- The schema emits additionalProperties: false on objects, so unexpected keys fail validation. Toggle off if your real data has more fields than your sample.
- JSON Schema runs at runtime (Ajv, Zod-from-schema, etc.) — useful for API request validation, config loading and form generation. TypeScript types are compile-time only. snip has a separate JSON-to-TypeScript tool for the latter.