02 Infer

JSON to JSON Schema

Paste one or more JSON samples and get a schema that fits all of them: merged types, required fields, detected formats and, if you like, enums.

Code editor. Press Escape, then Tab, to move focus out of the editor.

One document, several separated by a line with ---, or JSON Lines. Open or drop several files to use each as a sample.

Loading…

How to generate a schema from JSON

  1. Paste a JSON document, or several separated by a line containing only ---. JSON Lines (one document per line) works too, and you can open or drop several files at once.
  2. Adjust the options. The schema on the right updates as you type.
  3. Copy or download the result, or save it to your stash to validate data, generate TypeScript or Zod, and write docs.

What the options do

Draft
Sets $schema and which formats may be used: uuid needs Draft 2019-09 or later and date needs Draft 7 or later.
Detect formats
Adds format (date-time, date, email, uri, uuid, ipv4) when every value of a field matches it.
Detect enums
Turns small sets of repeated strings, such as a status field, into an enum. Leave it off when the samples do not show every possible value.
additionalProperties: false
Closes every object so unknown keys are rejected.
Top-level array is a list of samples
Treats [{…}, {…}] as separate samples and describes one item instead of the array.

FAQ

Why give it more than one sample?

One sample only shows one shape. With several, the generator can tell which fields are always there (required), which are optional, and which can be null or change type.

Is the generated schema final?

Treat it as a strong first draft. It describes the samples it saw; add descriptions, tighten limits such as minLength or maximum, and review formats and enums before relying on it.

Are my samples sent anywhere?

No. The schema is generated in your browser, and nothing is uploaded.