JSON Schema Generator

Infer a JSON Schema from a sample payload — draft 2020-12, 07, 06 or 04 — with email, uri, date-time, date, time, uuid and ipv4 formats detected for you.

You can also drop a .json file onto the box.

Draft 2020-12 is the current standard — pick it unless the validator this schema is for says it only understands Draft-07 (older Ajv builds, many code generators).

Every field required is a strict starting point. A real schema usually lists only the fields that must be present, so untick this, or trim the required list afterwards.

Unticked, the schema accepts keys it does not list — JSON Schema’s own default. Ticked, every object gets "additionalProperties": false. Extra array items need no switch: "items" already describes every element, however many there are.

Generate a JSON Schema from a sample

Paste any JSON payload and get a JSON Schema that describes its shape — objects become properties, arrays get a merged items schema, and each value is typed as string, number, integer, boolean or null. Choose draft 2020-12, draft-07, draft-06 or draft-04, and toggle whether every object key is listed as required. Two more boxes, both off by default: Add examples from the sample gives each string, number and boolean an examples list of the sample’s own values, and Refuse keys the sample did not have puts "additionalProperties": false on every object. Two more, also off: Infer an enum from repeated values turns a string field whose sample values repeat among a few choices into an enum, and Arrays of mixed kinds position by position (tuple) writes such an array as a closed tuple. Check the sample against this schema runs the site’s own validator on the sample and the schema and says whether the sample passes, or where it fails. Indent writes the schema with 2 spaces (the default), 4 spaces or a tab, and a .json file can be dropped onto the sample box as well as opened; the download is named after it, so users.json comes back as users.schema.json.

Automatic string formats

String values are inspected for common formats and annotated automatically: email, uri, date-time (ISO 8601), date, time, uuid and ipv4. A time needs its zone, as RFC 3339 and the validators that follow it do, so 09:30:00Z is a time and 09:30:00 is left as a plain string. Everything runs in your browser, so even sensitive payloads never leave your device.

Frequently asked questions

Which JSON Schema drafts are supported?

Draft 2020-12, Draft-07, Draft-06 and Draft-04. Pick one from the Draft dropdown; the generated $schema URI and structure match your choice. For what this generator writes, the older drafts differ in two places only: Draft-04 has no examples keyword, so the sample values are left out and the page says so, and a tuple is written as an items list rather than prefixItems.

How are array items handled?

All elements of an array are merged into a single items schema — unless Arrays of mixed kinds position by position (tuple) is ticked, when an array whose elements are of more than one kind is written as a closed tuple, one schema per position. For an array of objects, the properties are unioned and a key is marked required only when it appears in every element.

What string formats does it detect?

It recognizes email, uri, date-time (ISO 8601), date, time, uuid and ipv4, adding a format keyword when a value matches. A date has to be one the calendar has, and a time or date-time has to carry its zone, so that the sample passes its own schema. Plain strings stay as type string with no format.

Can the schema carry examples, or refuse keys the sample did not have?

Yes — both are boxes, off by default. Add examples from the sample gives every string, number and boolean an examples array of the values the sample had there, merged across the elements of a list up to the cap its label names. Refuse keys the sample did not have puts "additionalProperties": false on every object, nested ones and list elements included; unticked, extra keys are allowed, which is JSON Schema’s own default. Arrays need no such switch, because the one items schema already covers every element.

Can it infer enums or tuples, or check the sample?

Yes. Infer an enum from repeated values, off by default, gives a string field an enum when its sample values repeat among a few choices, pooled across the records of a list; values seen once each are left as free text, and one value every time is not a choice. Arrays of mixed kinds position by position (tuple), also off, writes such an array as a closed tuple, so an object’s properties are kept. Check the sample against this schema runs the site’s own validator (Ajv with ajv-formats) on the sample and the schema on screen and says whether it passes, or where it fails; the validator is loaded the first time you press it.

Can I drop a file in, or choose how the schema is indented?

Yes. Drop a .json, .jsonc or .txt file onto the sample box and it is read the way Open file… reads one — the same size limit, the same handling of its text encoding — and its name carries over to the download, so users.json comes back as users.schema.json; any other kind of file is refused with a message. The Indent menu writes the schema with 2 spaces (the default), 4 spaces or a tab. The quotes stay double, since single quotes would not be JSON.