JSON Schema Generator

Paste a sample of your JSON and get a JSON Schema for it, draft 2020-12. Types, required keys and string formats are inferred from the sample, on this page.

How it works

The sample is read with a parser that keeps the exact text of numbers, so 7 is an integer and 7.0 is a number, as written.

Every item of an array is merged into one description. A key that appears in every object is required. A key that appears in only some is optional. A value seen with two types gets both, such as ["string", "null"], and an integer seen beside a decimal becomes number.

With formats on, a string is marked date-time, date, email, uri or uuid only when every sample of it matches that format.

How to use it

  1. 1 Paste a JSON sample. Several records in an array give a better schema than one.
  2. 2 Leave Detect formats on, or switch it off if your strings only look like dates or emails by chance.
  3. 3 Read the schema. Check that the required keys and types match what your data really allows.
  4. 4 Press Copy result or Download .json.

Good to know

  • Paste the widest sample you have. A key that never appears in it cannot appear in the schema.
  • If a field can be null, include a record where it is null, so the type includes null.
  • The schema allows extra keys, as JSON Schema does by default. Add "additionalProperties": false yourself to forbid them.
  • An empty array gets type array with no items rule, because there is nothing to infer from.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

Writing a JSON Schema from real data

A JSON Schema is a JSON document that describes other JSON documents. It says which keys an object has, which ones are required, and what type each value is. Validators such as Ajv check data against it, API tools use it to describe requests and responses, and editors use it to suggest keys as you type. Writing a schema by hand for a large payload is slow and easy to get wrong. Starting from a real sample and correcting the result is much faster.

This generator reads your sample and describes what it sees. Objects become type object with a properties list. Lists become type array with one items rule. Text, booleans and null get their own types. Numbers are split into integer and number using the digits you wrote, so 42 is an integer and 42.5 is a number. If one sample has 1 and another has 1.5 at the same place, the schema says number, because that covers both. The output declares draft 2020-12, the current version of the standard.

The useful part is how arrays are handled. Real data is a list of records, and records differ. The generator merges every item into one description. A key found in every record is listed as required. A key found in only some records is optional. A value that is sometimes text and sometimes null gets the type ["string", "null"]. So the more records you paste, the closer the schema gets to the truth. One record tells the tool almost nothing about which keys are optional.

String formats are detected when you leave the switch on: date-time, date, email, uri and uuid. A format is kept only when every sample of that string matches, so one free-text value turns it off. Formats are hints in draft 2020-12, and many validators only check them when asked, but they document the intent well. If your strings only look like dates by chance, switch detection off.

A generated schema is a starting point, not a finished contract. It cannot know your rules: that a price is never negative, that status is one of three words, or that extra keys are forbidden. It allows extra keys, which is the JSON Schema default. Add enum, minimum, pattern and additionalProperties where they matter. Everything runs in this page, so you can build a schema from production data without sending that data anywhere.

Frequently asked questions

Which version of JSON Schema does it write?

Draft 2020-12, the current version. The $schema line says so, and validators such as Ajv 8 read it.

How does it decide which keys are required?

A key is required when it appears in every object that sits at that place in the sample. If one record in an array lacks it, it is optional.

Can it add enums, minimums or patterns?

No. Those are rules about what your data should be, and one sample cannot tell them. The tool writes the structure, and you add the rules you know.

Is my JSON uploaded?

No. The schema is built in this page from up to 2 MB of JSON at a time.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.