JSON to JSON Schema Generator
This JSON to JSON Schema generator produces a draft 2020-12 schema describing a sample payload: object properties with their inferred types, a required list built from the fields present in every record rather than just the first, and item schemas for arrays unified across all elements. additionalProperties is set to false, which makes the schema strict — the right default when you are validating your own data and want typos caught, and the wrong one when consuming an API that may add fields without warning, so change it in that case. Everything runs in your browser.
How it works
Paste a representative JSON sample and the JSON Schema declarations appear on the right. The types are inferred from what is actually in the sample, so the more complete your example, the better the result — one array element with an extra field is enough to have that field marked optional rather than missed.
Produces a draft 2020-12 schema describing the sample: object properties with their types, a required list built from the fields present in every record, and item schemas for arrays.
additionalProperties is set to false, which makes the schema strict. Relax it by hand if the payload is allowed to carry fields you have not seen yet.
Generation runs entirely in your browser — nothing you paste is uploaded.
How to generate a JSON Schema
- Paste a representative JSON payload into the input on the left.
- Set a title for the schema if you want one.
- Copy the generated schema and use it for validation.
What the schema describes
- Object properties with their inferred types.
- A
requiredlist built from the fields present in every record, not just the first. - An
itemsschema for arrays, unified across all elements. additionalProperties: false, which makes the schema strict.
Strict by default, on purpose
Setting additionalProperties to false means a payload carrying an unexpected field is rejected. That
is the right default when you are validating your own data and want typos caught, and the wrong one when you are
consuming an API that may add fields without warning. Change it to true in that case.
Draft 2020-12
The output declares the 2020-12 draft, which is what current validators default to. Older validators pinned to
draft-07 will still read the structure, but change the $schema line to match if yours is strict.
Give it a representative sample
The types are inferred from the data you paste, so the quality of the output depends on how complete your example is. Two things are worth including: an array with more than one element, so fields that appear in some records but not others get marked optional rather than assumed mandatory; and real values rather than placeholders, so numbers are recognised as numbers and whole numbers are told apart from decimals.
What inference cannot tell you
A sample shows what the data was, not what it can be. A field that happened to be null in every record you pasted has no discoverable type, and an enum looks exactly like a string. Treat the generated schema as a first draft that saves the typing, then tighten the parts you know more about than the sample does.
Frequently asked questions
How is the required list decided?
A property is required only if it appears in every record examined, not just the first. Paste an array with several elements and the distinction between mandatory and optional becomes accurate.
Why is additionalProperties set to false?
It makes the schema strict, so an unexpected field is rejected — which is what you want when validating your own data and catching typos. Set it to true when consuming an API that may add fields without notice.
Which draft does it target?
Draft 2020-12, which current validators default to. Older validators pinned to draft-07 will still read the structure; change the $schema line if yours is strict about it.
Does it infer formats like date-time or email?
No. Those look like ordinary strings in a sample, so adding a format keyword would be a guess. Add them by hand where you know the constraint holds.
Is my JSON sent anywhere?
No. The schema is generated entirely in your browser.
Related tools
JSON to TypeScript Converter
This JSON to TypeScript converter turns a sample payload into exported interfaces.
JSON Validator
This JSON validator checks syntax instantly and pinpoints the exact line and column of any error.
JSON to Python Dataclass Converter
This JSON to Python converter generates typed dataclasses with snake_case field names.