JSON to JSON Schema generator
Turn an example document into a schema you can validate against, without writing it by hand.
- 100% free
- No sign-up
- Runs in your browser
How to use JSON to JSON Schema
- Paste sample JSON
- Choose the rules
- Copy the schema
Report a problem with this tool
How to use JSON to JSON Schema
Paste sample JSON
Paste a document or open a .json file. Syntax mistakes are reported with their line and column.
Choose the rules
Pick the draft, whether properties are required, whether extra properties are allowed, and whether to detect formats and add examples.
Copy the schema
The schema updates as you change options. Copy it or download it as schema.json.
Why use Utils365
Arrays are merged properly
Every item of an array is read. A property found in only some items is described but not required, and values that are sometimes null become nullable.
Careful with numbers
Whole numbers become integer and decimals number. Very large values such as 12345678901234567890 are kept exactly in examples, not rounded.
Several samples, one schema
Put a few example documents in an array and tick one option to merge them into a single schema for one document.
Private by design
The JSON is read in your browser and never sent anywhere, so real API responses and configuration files are safe to paste.
Frequently asked questions
How are required properties decided?
A property is required when every sample object at that place has it. In [{"id": 1, "name": "a"}, {"id": 2}] the items require id but not name. A property whose value is null still counts as present. Turn the option off to leave out required altogether.
What happens with mixed types?
Simple types are listed together, so [1, "a"] gives items of type ["string", "integer"], and a value that is sometimes null gets "null" added to its type. When the types need their own rules, such as an object in one item and a string in another, the schema uses anyOf with one branch per type.
Which string formats are detected?
date (2024-05-01), date-time (2024-05-01T10:00:00Z, with a time zone), email, uri (with a scheme such as https://), uuid and ipv4. The format is written only if every string seen in that place matches the same one, and the checks lean towards leaving a format out, because a wrong one would reject valid data. They can’t read minds, though: a four-part version number such as 1.2.3.4 looks exactly like an IPv4 address, so check the formats or turn the option off.
What is the difference between draft 2020-12 and draft-07?
For the keywords this tool writes (type, properties, required, items, additionalProperties, anyOf, format, examples) the two read the same; only the $schema line differs. Choose draft-07 if your validator or code generator does not support the newer drafts yet.
Why is 1.0 a number and not an integer?
A value written with a decimal point or an exponent is taken as a sign that decimals can occur there, so it becomes number, which also accepts whole numbers. Values written with digits only become integer. If one place has both, the result is number.
What does an empty array become?
An array with items: {} — any items are allowed, since there was nothing to learn from. If another sample has the same array filled in, its items are used instead.
Is the generated schema complete?
It describes what the sample shows and nothing more. It cannot know about lengths, ranges, enums, patterns or properties your sample happens to lack, so read it through and tighten it. JSON nested more than 200 levels deep is refused.