JSON Schema Generator
Generate a Draft 2020-12 JSON Schema from example JSON. The draft describes observed value types and required fields, so you can review the rules before using them to check incoming data.
If you need declarations to use in TypeScript code, generate TypeScript types from the same sample.
- Use it when
- You need rules for what JSON an app should accept, such as which fields are required and what types they can have.
- Keep in mind
- The tool drafts a schema from your sample. Review it and use a schema validator to check other files against it.
{"id":7}{"type":"number"}This output is inferred from your sample. Review it before use.
Your input stays in this browser. We don’t upload it. How we handle your data .
How to generate a JSON Schema
Paste example JSON or open a file and select Generate JSON Schema. Review the inferred types and required fields before downloading it.
Frequently asked questions
What is JSON Schema used for?
A JSON Schema describes what data a document should contain. For example, it can require an id field and specify that its value must be a number. A schema validator can then check other documents against those rules.
How does the generator decide which fields are required?
A field is marked required when it appears in every sampled object at that location. Include examples with missing fields if they are optional, and review the generated required list before using the schema.
Does the generated schema prevent extra fields?
The generated schema allows extra fields by default. To reject keys beyond the ones you define, review the relevant object schema and set additionalProperties to false where appropriate.
Which version of JSON Schema does the tool generate?
The generated schema declares Draft 2020-12. Use a validator that supports that version, then test the schema with examples that should pass and examples that should fail.