About the JSON Schema generator
Writing a schema by hand for an existing API is tedious and error-prone. This infers one from a sample: types, nested objects, arrays, formats such as date-time, uuid and email, and closed sets of strings as enums. Array elements are merged rather than sampled, so the items schema describes every element — the union of their properties, with only the always-present keys marked required.
How to use it
- Paste a representative payload — the more variation it contains, the better the schema.
- Choose the draft, and switch on the detections you want: formats, enums, examples, additionalProperties: false.
- Copy the schema, or download it as schema.json.
Questions
Which drafts can it emit?
Draft 2020-12 (the current one) and draft-07 (the one most tooling still targets).
How does it decide what is required?
A key is required only if it appears in every object of that shape in your sample. That is why feeding it an array with several varied elements gives a much better result than a single object.
Is the generated schema production-ready?
Treat it as a first draft. Inference from one sample cannot know your real bounds, nullability or optionality — check those before shipping it, then test it against real payloads with the schema validator.