JSON Schema Generator
Generate a JSON Schema (draft 2020-12) from sample data, with types, required properties, and detected string formats.
What is inferred
typefor every value, distinguishingintegerfromnumber.requiredlists every key present in the sample. For arrays of objects, only keys present in every item are required.- String
formathints:date-time,date,email,uri,uuid. - Nested objects and arrays get their own
propertiesanditemsschemas, as deep as the sample goes.
Treat the output as a starting point and tighten constraints (enums, min/max, patterns) by hand.
Where to use the generated schema
Validate request bodies in Express, Fastify or FastAPI, document an API in OpenAPI 3.1 (which uses JSON Schema 2020-12 directly), add editor autocompletion for a configuration file, or guard a data pipeline against malformed records.
Like every tool on TheJSON, this runs entirely in your browser. Nothing you paste is uploaded, logged or stored on a server, so it is safe to use with API responses that contain tokens or customer data.
Frequently asked questions
Which JSON Schema draft is generated?
- Draft 2020-12, the current version and the one OpenAPI 3.1 uses. It is backwards compatible with draft 2019-09 validators for the keywords produced here.
Can I validate JSON against the schema here?
- Not yet. Copy the schema into your test suite or API framework; Ajv (JavaScript), jsonschema (Python) and every major language have a validator that accepts 2020-12 schemas.
Why are some fields not marked required?
- For an array of objects, a key is required only if every item has it. If your sample has one record missing a field, that field is optional in the schema. Supply a fuller sample or edit the required list.