JSON Schema Generator
Guide: Turn JSON or XML Into Classes (DTOs) in Java, C# and More
For the best schema, use a list of several example objects so optional keys are spotted.
Nothing you enter or choose here leaves your device. This tool runs in your browser.
A sample in, a schema out
Paste a sample of your data and the tool writes a JSON Schema describing it. Give it a list of two examples:
[{"id":1,"email":"a@b.co","name":"Ann","tags":["x"]},
{"id":2,"email":"c@d.co","name":"Bo"}]and you get a schema that says: the data is an array of objects. Each has an id that's an integer, an email that's a string in email format, a name that's a string, and tags, an optional array of strings. The required list holds id, email and name, because those appear in both examples. tags is left out of it, since the second example doesn't have one.
Why more examples give a better schema
The tool can only describe what it sees. With one record, every key looks required, and every number looks like the only number there is. Feed it several records, including awkward ones with missing fields, nulls and empty lists, and the schema learns which keys are optional and which types are mixed.
The options
| Option | Does | Use when |
|---|---|---|
| Detect formats | Adds format for email, date, date-time, uuid, uri and ipv4 when every string in a field matches | You want stricter checks on strings |
| Mark required keys | Lists the keys present in every object | You want missing fields caught |
| Block extra properties | Sets additionalProperties to false | Unknown keys should be rejected |
Blocking extra properties is strict. It's good for an API you control, and harmful for data that gains new fields over time, since a harmless new key would then fail validation.
Treat the result as a first draft
A generated schema can't know your rules. It doesn't know that age must be at least 0, that status can only be one of three words, or that a code must be exactly six characters. After generating, tighten it by hand:
- Add
minimumandmaximumfor numbers. - Add
enumfor fields with a fixed set of values. - Add
minLength,maxLengthorpatternfor strings. - Add
descriptionso the schema documents itself.
Using it
The schema follows draft 2020-12. Basic keywords like type, properties, required and items work in every draft, so if your tool expects an older one, delete the $schema line. Validate with a library such as Ajv in JavaScript or jsonschema in Python, or use it in OpenAPI tooling and editor autocomplete.
Your sample stays in your browser. To build code types from the same sample, use the JSON to DTO generator, and to look up a value inside the data, the JSONPath tester. The JSON formatter checks that your sample is valid first.
Written by Akinrinmade Michael · Updated October 24, 2026
How to use
- 1Paste a sample JSON document, or a list of examples.
- 2Choose whether to detect formats, mark required keys and block extra properties.
- 3Read the generated schema.
- 4Click Copy schema.
Frequently asked questions
How does it work out the schema?
It reads the types of your sample, merges the items of any list, and notes which keys appear in every object. A list of several examples gives the best result.
What does detecting formats do?
It adds a format keyword, such as email, date, date-time, uuid, uri or ipv4, when every string in a field matches that pattern.
Which JSON Schema version is used?
Draft 2020-12. You can remove the $schema line if your tool expects another draft. Basic keywords such as type, properties, required and items work in all drafts.
Can I validate data with it?
Yes. Use the schema with a validator such as Ajv in JavaScript, jsonschema in Python or any OpenAPI tooling. Treat the result as a starting point and tighten it by hand.
Read the guides
Learn how this works and how to get the most from it.
Developer
Turn JSON or XML Into Classes (DTOs) in Java, C# and More
What a DTO is, how generated classes map JSON and XML, and the details to check before you trust a generated model.
3 min read
Developer
How to Fix the Most Common JSON Errors
Trailing commas, single quotes, unquoted keys and more. Learn to read a JSON error message and fix invalid JSON quickly.
4 min read
Related tools
JSON Formatter & Validator
Prettify, minify and validate JSON, with error line numbers.
JSON to DTO Generator
Turn JSON into Java, C#, TypeScript, Kotlin, Python or Go classes.
JSONPath Tester
Test JSONPath queries against your JSON and see every match.
JSON Diff
Compare two JSON documents and see what changed, ignoring key order.