How to use JSON Schema Generator
- Paste a representative JSON document.
- Copy the generated schema.
- Add required fields, enums, ranges and formats — that is where the validation lives.
- Decide on additionalProperties deliberately rather than leaving the default.
- Inference reads one sample: it cannot tell optional from present-this-time.
- Arrays are typed from their elements; an empty array gives no information at all.
- Declare $schema so validators apply the right draft’s rules.
What a schema buys you that a type does not
A TypeScript interface disappears at compile time and validates nothing at runtime. A JSON Schema is data, checked while the program runs, so it catches the case that actually breaks things: an upstream service changing its response shape. It is also portable — the same schema validates in JavaScript, Python, Go and Java, documents the API, and can generate types in several languages. One artefact, several jobs.
Inference gets you the shape and none of the rules
From one sample a generator can see that age is a number and email is a string. It cannot know that age must be between 0 and 130, that email needs a format constraint, that status is one of four values rather than any string, or which fields are genuinely optional. Those constraints are where the value is — a schema that only records types catches a field disappearing and nothing else. Treat the output as scaffolding and add required, enum, minimum, maxLength and format by hand.
additionalProperties is the decision to make deliberately
By default a schema permits properties it does not mention, so an object with unexpected extra fields validates happily. Setting additionalProperties: false rejects them, which catches typos in config files and stops unexpected data flowing through your system. The trade is that it breaks forward compatibility: a client validating a server’s response strictly will reject it the day the server adds a field. Strict for config and inbound data you own; permissive for responses from services you do not control.
Choose the draft version and say which it is
JSON Schema has several drafts — Draft 7 is the most widely supported, and 2020-12 is current, with real differences in how $ref, items and tuple validation work. Declare $schema at the top so validators know which rules to apply, and check that your chosen library actually supports that draft. Mismatched assumptions here produce schemas that pass in one validator and fail in another.
Frequently asked questions
Does it infer required fields correctly?
Can I use this file directly on my live site?
Does this tool call any external API to generate the file?
How do I mark fields as required?
What is the difference between JSON Schema and TypeScript types?
Should I set additionalProperties to false?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.