JSON Schema Generator Online (Draft-07)
Free online JSON schema generator. Turn sample JSON into a Draft-07 schema with inferred types, a required array and optional example values. Nothing uploaded.
A JSON Schema generator reads sample data and writes the contract it satisfies. Paste JSON on the left and the right pane returns a Draft-07 schema with a type inferred for every key, a required array built from the keys present, and example values when you enable them.
A JSON Schema is a machine-readable contract describing which documents are acceptable. JSON2X infers one from a sample: types from the values, a required array from the keys present, properties for each object, items for each array, and string format hints such as email, uri, uuid, and date-time where a value matches a recognised pattern.
What can be inferred, and what cannot?
Inference sees structure, not intent. It can tell that status is a string; it cannot know the only legal values are active and archived — that needs an enum. It can tell age is an integer; it cannot know it must be between 0 and 130. It can tell tags is an array of strings; it cannot know it must be non-empty and unique. Treat the generated schema as the structural skeleton and add the business rules yourself. The single highest-value manual addition is usually "additionalProperties": false, which turns silent typos in config keys into errors.
How is `required` determined?
From presence across your sample. With one object, every key is present and therefore required — which is almost always too strict. With an array of records, only the keys appearing in all of them are marked required, which is usually right. This is the single biggest reason to paste multiple records: it is the only evidence the generator has about optionality, and an over-strict required array will reject valid production traffic.
Which draft should I target?
Draft-07 if you want the broadest library and tooling support — most validators, editors, and API frameworks handle it without configuration. 2020-12 is the current specification and the right choice for new work, particularly if you need prefixItems for tuple validation or the reworked $dynamicRef mechanism. The practical difference for a straightforward object schema is small; the difference in whether your validator supports it is not, so check the library before switching.
How to use the JSON Schema Generator
Takes under a minute. Nothing is uploaded — every step runs in this browser tab.
- Paste sample JSON
Put a representative document into the left-hand input pane. An array of several records yields a better schema than one object, because variation reveals which fields are truly required.
- Choose a draft
Select Draft-07 for the widest tooling support, or 2020-12 for the current specification.
- Read the schema
The right-hand pane shows the generated schema with types, required arrays, nested property definitions, and detected string formats.
- Tighten it by hand
Add the constraints inference cannot see — enums, minimum and maximum, pattern, and additionalProperties: false.
When to use it
- Publishing a contract for an API endpoint that currently has none
- Validating configuration files in CI before a deploy reads them
- Adding request-body validation to an Express, Fastify, or FastAPI route
- Driving editor autocomplete and inline errors for a config file in VS Code
- Generating a schema to hand to a client team as documentation
Step-by-step guides for this tool
Task-specific walkthroughs covering the most common ways this tool gets used.
Searches this page answers
- json schema generator online free
- free json schema generator
- generate json schema from json
- json schema generator from json
- json schema draft 07 generator
- infer json schema from sample
- json validator with schema
- api contract schema from json
- json to json schema converter
Frequently Asked Questions
What is JSON Schema?
JSON Schema is an IETF standard specification that validates the structure, constraints, and data types of JSON payloads, essential for automated API contract testing.
How do I generate a JSON Schema from existing JSON?
Paste one representative payload into the left pane. Every key is read to infer its type, nested objects and arrays are described recursively, and the keys present become the required array. Turn off "mark all keys as required" when some fields are optional.
Which JSON Schema draft does the output target?
Draft-07, declared via the $schema keyword. It has the widest library support — Ajv, Python jsonschema and everyday OpenAPI 3.0 work all accept it. To target 2020-12 instead, change the $schema URI and adjust keywords such as items to prefixItems where your validator requires it.
Can it add example values to the schema?
Yes. Enable the examples option and each leaf gets an examples array carrying the value from your sample — useful when the schema doubles as documentation.
Is this JSON schema generator free, and is my sample uploaded?
It is free with no account, and nothing is uploaded. Inference runs in your browser, so a real API response used as the sample stays on your machine.
Related Developer Tools
- Standards & references:
- JSON Schema
- JSON
Last reviewed by the JSON2X Engineering Team.