Skip to content
snip tools

JSON Schema generator

Generate a JSON Schema from sample data — Draft 2020-12, with required-field inference.

Runs 100% in your browser
 

How to generate a JSON Schema

  1. Paste sample JSON. Any valid object or array. Arrays of objects produce the strongest schemas.
  2. Pick required-field policy. Strict marks every field as required; default only marks fields present in every record.
  3. 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

What is JSON Schema?
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.
How is the schema inferred?
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.
Will this catch unknown values?
The schema emits additionalProperties: false on objects, so unexpected keys fail validation. Toggle off if your real data has more fields than your sample.
Why JSON Schema instead of TypeScript types?
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.