About this JSON Schema generator
JSON Schema describes what valid JSON looks like, and it powers API validation, OpenAPI documents, form generators, editor autocompletion, and configuration checks. Writing one by hand for a large payload is slow, so this generator starts from real data. It walks every object and array, tells integers from decimals by the number text, merges all items of an array or all records of an NDJSON log into one schema, and marks a key as required only when every sample has it. It can recognize common string formats, suggest enums for repeated values, add examples, and close objects against unknown keys. Treat the result as a strong first draft: add descriptions and tighten rules your samples cannot show.
How to generate a JSON Schema
- Paste sample data. Use one JSON document, an array of objects, or one JSON record per line. More varied samples give a more accurate schema.
- Choose the options. Pick the draft your validator supports, add a title, and decide on required keys, formats, examples, enums, and closed objects.
- Press Generate schema. Copy or download the schema and check the path table for each inferred type and rule.
Frequently asked questions
Which draft should I choose?
Draft 2020-12 is the current version and is used by OpenAPI 3.1. Choose draft-07 for older validators, such as many versions of Ajv and some IDE plugins.
How are required fields decided?
A key is required when it appears in every sample object at that path. With a single sample, every key looks required, so paste several records for a realistic result.
How does it tell integer from number?
By the number text: 42 is an integer, while 42.5 or 1e3 is a number. If a field holds both across samples, it becomes number, which includes integers.
What are enum hints?
When a string field repeats a few values across samples, such as status ok or fail, the schema limits it to those values. Check that the list is complete before using it.
What does a closed object do?
additionalProperties: false makes validation fail when data contains keys that the schema does not list, which catches typos but also rejects new fields.