JSON Schema Generator
100% private — runs on your device, never uploaded. Works offline once loaded.
Turn a sample JSON document into a ready-to-use draft-07 JSON Schema. Types, nested objects, array item schemas and required fields are inferred automatically, entirely in your browser.
What a generated JSON Schema gives you
JSON Schema is a vocabulary for describing the shape of JSON data so it can be validated automatically. Instead of hand-writing rules, this tool reads one real example and works backwards to a schema that the example would satisfy. It walks your document recursively: objects become {"type":"object","properties":{...}}, arrays become {"type":"array","items":{...}}, and each leaf value is mapped to its JSON Schema type.
The result is a draft-07 document, complete with the $schema declaration, that you can hand to a validator such as Ajv, python-jsonschema, or the many language ports. It is a fast way to bootstrap request/response validation, config-file checking, or API contract tests without writing the schema by hand.
How type inference works
Every value is inspected by its JavaScript runtime type after JSON.parse. Strings map to "string", booleans to "boolean", and null to "null". Numbers are split: Number.isInteger decides between "integer" and "number", because JSON Schema treats them as distinct types even though JSON itself has a single number type.
Arrays get an items schema. When the array holds several objects with differing keys, the tool merges them into one object schema that covers the union of all keys, and marks a key required only when it is present in every element. If an array mixes fundamentally different types, they are combined under a oneOf so the schema still validates every element you supplied.
When to use it — and what it cannot know
Generating from an example is ideal for a first draft: you get correct structure and types in seconds, then tighten the rules by hand. It is perfect for documenting an existing API payload, seeding contract tests, or explaining a data format to a teammate.
- A single example cannot reveal constraints like minLength, format (email, date-time), enum values, or numeric ranges — add those manually.
- Optionality is only as good as your sample: feed an array with varied objects so genuinely optional keys are detected.
- An empty array yields an untyped items schema, because there is nothing to infer from.
- Always review required arrays before shipping — one unrepresentative example can over- or under-constrain them.
Frequently asked questions
Can I generate a schema from an array of records?
Yes. Paste a JSON array and the tool infers a single items schema by merging every object in the array, so the schema validates the whole collection rather than just the first row.
Are optional fields detected?
When you supply an array of objects, a key that is missing from some elements is left out of the required list, effectively marking it optional. With a single object every key is treated as required.
Does it add formats like email or date-time?
No. Formats, patterns and value ranges cannot be inferred from a single example without guessing, so the tool leaves them out. Add format, pattern, minimum and similar keywords yourself where you need stricter validation.
Is my JSON uploaded anywhere?
No. Parsing and schema generation run entirely in your browser using local JavaScript. Nothing is sent to a server.
What happens if my JSON is invalid?
The tool reports the parser error message inline so you can fix the syntax. No schema is produced until the input parses cleanly.
Which validators accept the output?
Any draft-07-compatible validator, including Ajv (JavaScript), python-jsonschema, everit-org/json-schema (Java), and most other language implementations.
Advertisement