How this tool fits your workflow
What a generated schema gives you
A JSON Schema is a machine-readable description of what a valid document looks like. Unlike TypeScript types, it survives to runtime, so a validator can reject a malformed payload at the boundary of your system rather than letting it propagate.
Writing one by hand for a large document is slow. Generating from a real sample gets the structure right immediately, and leaves you to add the parts that require judgement: constraints, formats, and which fields are genuinely required rather than merely present in your sample.
Worked example: a user record
A sample with mixed numeric types, an array, and a nested object produces:
- Paste a representative document into the left pane.
- Read the draft-07 schema on the right, with $schema already declared.
- Check the required array. Everything present in your sample is listed — remove any field that is genuinely optional in your API.
- Add constraints by hand: minLength on strings, minimum on numbers, format on emails and dates, enum where a field has a fixed set of values.
| Sample field | Value | Inferred schema |
|---|---|---|
| id | 42 | { "type": "integer" } |
| score | 9.5 | { "type": "number" } |
| "ada@example.com" | { "type": "string" } | |
| verified | true | { "type": "boolean" } |
| tags | ["admin", "beta"] | { "type": "array", "items": { "type": "string" } } |
| profile | { "city": "London" } | { "type": "object", "properties": { ... } } |
What to tighten by hand
- Formats. A string holding an email is just "string" to the generator. Adding "format": "email" or "format": "date-time" gets you real validation.
- Enums. A status field that is always one of three values should be an enum, not an open string. The generator cannot know the full set from one sample.
- Ranges. minimum, maximum, minLength and maxLength encode business rules that no sample can reveal.
- additionalProperties. Draft-07 allows unknown keys by default. Setting it to false makes the schema strict, which is usually what you want for an API contract.
- Required. The generator marks everything in your sample as required. That is almost always too strict for a real API.
When not to use this
Related workflow
For compile-time safety in a TypeScript codebase, the JSON to TypeScript converter generates interfaces from the same sample. The two are complementary: types catch mistakes while you write code, schemas catch bad data while it runs.
To build a schema from many records rather than one, convert your log or dataset with the JSONL converter into an array and paste that — merging across elements produces a far more accurate required list.
The JSON formatter validates a document before you generate from it, and the JSON diff tool helps when comparing two versions of a payload to see which fields actually vary.
Frequently asked questions
- Which JSON Schema version does it produce?
- Draft-07, declared in the $schema field. It is the most widely supported draft across validation libraries in every major language.
- How are required fields decided?
- A key is required if it appears in every sample of that object. Inside an array, elements are merged first, so a key present in only some elements is not marked required.
- Why is one field "integer" and another "number"?
- JSON has one numeric type, but JSON Schema distinguishes them. A value with no fractional part is typed integer; anything else is number. If a field can be either, the sample showing a decimal is the one to use.
- Can I use the output to validate data?
- Yes, with any draft-07 validator — Ajv for JavaScript, jsonschema for Python, everit for Java. The generated schema is a starting point that you should tighten by hand.
- Does it add descriptions or formats?
- No. It infers structure and types only. Adding format keywords such as "email" or "date-time", along with descriptions and value constraints, is deliberate work you do afterwards.