Contact

Tools  /  JSON  /  JSON Schema Generator

JSON Schema Generator

Infer a JSON Schema from one example or an array of examples -- merges types across records, detects required fields, string formats, numeric/length ranges, and can export a TypeScript interface or a Zod schema instead.

What this tool does

Paste one JSON example, or an array of several, and get back a schema describing its shape — types, which fields are required, detected string formats, and numeric or length ranges — inferred from the actual data rather than written by hand.

Why several examples produce a better schema than one

A schema built from a single example cannot really know which fields are always present versus only sometimes there — everything looks required because there is nothing to compare against. Given an array of examples instead, each field is tracked across all of them: a field appearing in every example is marked required, one that only shows up in some is left optional, and if a field's type actually varies between examples, the schema records a union of the types actually observed instead of picking one arbitrarily.

What gets detected automatically

  • String formats — email, UUID, date-time, date, IPv4, and URI, each only assigned when every observed value for that field actually matches it.
  • Numeric ranges — the minimum and maximum value seen for a numeric field.
  • Length ranges — for strings and arrays, the shortest and longest actually observed.

Each of these is optional, since a generated schema is a starting point to review, not something to accept unread.

Getting code instead of a schema

The same inferred structure can be exported three ways: as a JSON Schema document (choosing from Draft-04 through 2020-12), as a TypeScript interface with required and optional fields marked correctly, or as a Zod schema with the detected formats and ranges translated into the matching Zod method calls, ready to drop straight into a project that validates with Zod instead of raw JSON Schema.

Privacy

Parsing and schema inference both happen in your browser. Nothing you paste, drop, or load from a file is sent to a server.

Frequently asked questions

Is my data uploaded anywhere?
No. Parsing and schema inference both run locally in the browser — nothing is sent to a server.
Why would multiple examples work better than just one?
From a single example there is nothing to compare against, so every field would have to be treated as required. With an array of examples, each field is tracked across all of them, so a field present in every example is marked required while one that only appears sometimes is correctly left optional.
How does it decide which fields are required?
By default, a field is marked required only if it appeared in every example provided. Modes to mark every field required or none are also available for when that default heuristic is not what is wanted.
What string formats can it detect?
Email, UUID, date-time, plain date, IPv4, and URI. A format is only applied to a field when every observed value for that field actually matches it, so a field with mixed content does not get a format assigned incorrectly.
Can it generate TypeScript or Zod code instead of a JSON Schema?
Yes — the same inferred structure can be output as a JSON Schema document, a TypeScript interface, or a Zod schema, with detected formats and ranges translated into the corresponding Zod method calls.
Which JSON Schema draft versions are supported?
Draft-04, Draft-06, Draft-07, 2019-09, and 2020-12, selected from a dropdown before generating.
Theme Accent