The quick answer
Paste JSON, get a draft 2020-12 JSON Schema: properties with inferred types, required lists, nested objects as inline definitions, and format hints like "email". The generator runs entirely in your browser, production payloads never upload, and the finished schema copies with one click.
The contract your API forgot to write
The endpoint shipped on a Friday. By the following Tuesday, three consumers had integrated against it, and by the Thursday after, someone's integration was broken because the `email` field came back `null` for one customer. The API documentation, such as it is, lives in a README that says the response "includes customer info." Nobody wrote down which fields exist, which are optional, what types they hold, or what shape the nested objects take. The API has a contract; it is just an oral tradition.
A JSON Schema is that contract, written down in a form both humans and machines can enforce. It states, for every object your system produces or accepts: which properties exist, which are required, what type each holds, how long strings may be, which values an enum permits, and what shape nested structures take. Given a schema, validators can reject malformed payloads at the edge, code generators can build types in a dozen languages, and documentation generates itself. Given only example responses, developers guess, and the guessing is where the null-email bug was born.
The JSON Schema Generator above bridges the gap in the practical direction: paste a real response, get a draft 2020-12 schema with inferred types, required lists, format hints, and nested definitions. It runs in your browser, which matters because the JSON people paste into schema generators is overwhelmingly real production data. In the last two years it acquired a second life nobody fully anticipated: the same schemas now steer structured LLM output.
From JSON to schema in five moves
The path from sample to contract is deliberately short, and the interesting part is what you do after the schema appears: the refinement loop below.
Paste your JSON
Any valid document: an API response, a config file, a message payload. The parser validates syntax first; if a trailing comma sneaks in, the error message points at it before any generation happens.
Let inference run
The tool walks the document: objects become properties, arrays get item schemas, values determine types, and repeated array elements are merged into one combined shape rather than one schema per index.
Choose your strictness
One toggle sets the required list: 'All properties required' is the safe contract default, 'No required list' the documentation flavor. Refine the list by hand after copying; the toggle is deliberately all-or-nothing.
Check the dialect
The output is standard draft 2020-12, fit for general use. If it is headed for an LLM's structured output or function calling, trim it by hand to the core the provider documents (type, properties, required, enum, array keywords), and set additionalProperties deliberately, because runtimes differ on it.
Copy and refine
The Copy schema button puts the draft on your clipboard; take it into your repo as a .schema.json file and tighten it there: enums for closed sets, patterns for formats that matter, bounds on lengths.
Draft 2020-12, keyword by keyword
The 2020-12 revision is the current anchor of a specification that has been evolving for over a decade, and its vocabulary is what every generated schema speaks. Below are the keywords that matter, the ones the generator emits and the ones you will add by hand, and what each asserts:
| Keyword | What it does | Example |
|---|---|---|
| $schema | Declares which dialect this schema speaks | "https://json-schema.org/draft/2020-12/schema" |
| type | The JSON type a value must have | "string", "number", "integer", "boolean", "object", "array", "null" |
| properties | The allowed members of an object | {"name": {"type": "string"}} |
| required | Which properties must be present | ["id", "name"] |
| items | Schema for array elements | {"type": "object"} |
| prefixItems | Schemas for tuple-style leading positions | An ordered list before items applies |
| enum | The closed set of permitted values | ["admin", "editor", "viewer"] |
| const | Exactly one permitted value | "v2" |
| pattern | ECMAScript regex a string must match | "^[A-Z]{2}\\d{4}$" |
| minLength / maxLength | String length bounds | 8 / 64 |
| minimum / maximum | Numeric bounds | 0 / 100 |
| format | A semantic annotation, not a default assertion | "email", "date-time", "uuid" |
| additionalProperties | Whether extra object members are allowed | false for closed objects |
| $defs + $ref | Reusable sub-schemas, referenced by pointer | "$ref": "#/$defs/Customer" |
Three of those keywords carry history worth knowing. `format` was demoted from assertion to annotation: a schema with `format: "email"` describes a string as an email without promising to reject non-emails, unless the validator opts into format checking explicitly. `definitions` became `$defs` in draft 2019-09, so older schemas you meet in the wild use the previous spelling and older validators expect it. And `items` changed semantics across the array-tuple boundary: pre-2019 schemas used an array form of items for tuples, which 2020-12 replaced with `prefixItems` plus a single-schema `items` for everything after. When a generated schema or a legacy one misbehaves in an old validator, the draft mismatch is the first suspect.
Composition keywords (`allOf`, `anyOf`, `oneOf`, `not`) are how schemas express or-logic and inheritance. `oneOf` is the strict sibling: exactly one branch must match, no more, which makes it the right tool for variant shapes (a response that is either a success or an error, never both) and the wrong one for overlapping merges. The generator reaches for these when a sample can't be described by a single type: a `null` value comes out as a type array allowing null, and an array with mixed element types merges them via `anyOf`, which is more honest than pretending everything was a string.
A payload and its schema, line by line
Here is the full pipeline on a realistic customer object, the kind of shape an account service returns and an integrator curses at:
{
"id": 42,
"name": "Ada Lovelace",
"email": "ada@example.com",
"role": "admin",
"tags": ["math", "pioneer"],
"address": {
"city": "London",
"postcodes": ["W1", "SW1"]
},
"active": true
}{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"id": { "type": "integer" },
"name": { "type": "string" },
"email": { "type": "string", "format": "email" },
"role": { "type": "string" },
"tags": { "type": "array", "items": { "type": "string" } },
"address": {
"type": "object",
"properties": {
"city": { "type": "string" },
"postcodes": { "type": "array", "items": { "type": "string" } }
},
"required": ["city", "postcodes"]
},
"active": { "type": "boolean" }
},
"required": ["id", "name", "email", "role", "tags", "address", "active"],
"title": "Generated schema"
}The nested `address` object became an inline definition with its own `required` list, and the sample's `email` value earned a `format` hint. Notice what the generator deliberately does not emit: `additionalProperties`. Closing objects is a strictness decision with consequences: a closed object rejects any field the schema doesn't name, which catches typos like `adress` at validation time but also breaks forward compatibility the day the API adds a legitimate new field. Open objects (omit the keyword, or set it true) tolerate additions and typos alike. Add the keyword by hand when you want the closed default; leave it out when you want the schema to age more gracefully than the API.
What inference can and cannot know
A generator sees one document and must generalize to a population. The honest list of what that costs:
- Required is a guess about intent. Present in the sample reads as required; optional fields that happened to appear look mandatory. Generate from two or three representative samples and compare the outputs, or hand-tune the required list after copying.
- Integer versus number is one value's evidence. Widen `integer` to `number` whenever fractional values are conceivable: API clients that send `42.0` fail integer assertions on some validators.
- Single observed values can't prove closed sets. The enum candidate problem from the worked example. Two samples with different values turn the suggestion concrete.
- Arrays with one element flatten the shape. The generator merges multiple elements when present; a single-element array describes its only citizen, and a future heterogeneous array will surprise the schema.
- Nullability is invisible until it happens. A field that is `null` for some records needs `anyOf` with `null`, something a sample where it was always a string cannot show. Real-world payloads are full of these, and they are precisely the fields that break integrations.
The design answer to all five is the same: generation is a first draft, and the tool behaves like it, with a preloaded example you can verify against, an all-or-nothing required toggle, format hints only where the sample supports them, and a copy button rather than a pipeline straight into production. The failure mode this design works against is the one where a generated schema gets pasted into production unreviewed and treated as gospel. A schema is a contract, and contracts deserve review.
The AI-shaped reason schemas are booming
For fifteen years, JSON Schema lived a quiet professional life: API contracts, config validation, message queues. Then LLMs acquired structured output, and the specification's most obscure corner became mainstream plumbing. When you ask a model to answer in JSON rather than prose, the mechanism underneath is a schema: the API is told which properties to emit, their types, and which are required, and the provider's runtime steers generation toward conforming output.
The catch is that providers implement subsets of the specification, not the whole of it. The widely supported core is `type`, `properties`, `required`, `enum`, and array `items`; beyond that the ground shifts: `additionalProperties: false` is enforced by some runtimes and ignored by others, `$ref` support varies from full to absent, and the composition keywords are the most unevenly implemented of all. The practical answer is to trim by hand: keep to the conservative core (type, properties, required, enum, array items), set additionalProperties deliberately, and drop $ref where the provider rejects it, so a schema that validates in your tests also behaves at the API.
The workflow this enables has become standard practice for anyone building on LLMs: paste the exact response shape you want, generate, trim to the provider's core, test against the provider, iterate. Compared to hand-writing schemas (which nobody enjoys and everyone gets subtly wrong on the first attempt), generation plus a validation loop turns the fiddliest part of structured-output integration into a two-minute task.
Who writes schemas, and on which days
Schema-first workflows have spread across most teams that move data. The populations, and the moments they reach for generation:
API designers draft the contract before or alongside the endpoint; the schema becomes the source of truth that documentation, mock servers, and contract tests all read from. Backend integrators do the reverse-engineering direction: they have a response from someone else's undocumented API and need the shape as a schema to validate against or to generate types from.
Data engineers pin down event payloads before they land in a warehouse: a schema at the boundary turns downstream type errors into boundary rejections. LLM application developers, as the last section said, are the newest and fastest-growing group. And QA engineers use schemas as machine-checkable expectations in test suites: instead of asserting that a response contains an `email` string somewhere, they assert it validates against the contract, which catches missing fields, wrong types, and surprise additions in a single check.
The when is whenever a payload's shape stops being tribal knowledge: a new endpoint, a new integration, a new data pipeline, a migration to structured model output. That moment arrives weekly at most companies, which is why schema generation sits among the most steadily used developer utilities on the web rather than spiking with any season.
JSON Schema vs. TypeScript vs. Zod
| Approach | Enforced when | Portable to | Best at |
|---|---|---|---|
| JSON Schema (draft 2020-12) | Runtime, by any validator in any language | Everywhere: it is the lingua franca | Contracts across language boundaries, AI structured output, config validation |
| TypeScript types | Compile time, in the TypeScript toolchain | TS projects only | In-editor safety while you write application code |
| Zod schemas | Runtime, in JavaScript/TypeScript | JS runtimes; can export to JSON Schema | Colocating parse-and-validate at the edge of TS code |
The distinction that actually matters is the boundary. TypeScript types vanish at compile time: perfect for catching your own mistakes inside your own code, invisible to a Python consumer of your API or to an LLM runtime constraining a response. Zod runs at the boundary but lives inside the JavaScript world, which is why its community built a JSON Schema exporter for exactly the interop cases. JSON Schema's superpower is being nobody's favorite language's native feature: it is the neutral contract format that every language community learned to speak, the way HTTP headers are nobody's framework and everybody's protocol. The JSON to TypeScript Interface tool covers the compile-time side, this one the contract side, and mature teams frequently use both on the same payload.
Schemas are built on your machine
Parsing, inference, and generation are all pure client-side computation. The JSON you paste stays in your browser's memory; the schema is assembled there; the copy happens there. No upload, no history, no account, and no server that has ever seen your payload.
For this tool the stakes are unusually concrete. The JSON people bring to schema generators is rarely synthetic: it is a response captured from production, often containing real customer records, sometimes containing exactly the personal data a privacy policy promised to protect. A server-side generator would be building a database of production samples. The client-side design keeps the tool useful in the exact situations where it is most sensitive: pasting a payload from a system whose compliance posture you do not control, working on an air-gapped machine, or generating a contract for data you are not free to share with a third-party website. Architecture as the privacy policy: the same design we apply across every data tool on this site, from the JSON Formatter & Validator that likely brought your payload here in the first place to the converters in this cluster.
Validating against the schema
A schema nobody enforces is documentation with attitude. The fastest loop for learning the vocabulary is generate here, copy out, and validate: Ajv's playground, or a five-line script with Python's jsonschema, runs your sample against the schema, and every keyword you add either accepts your sample (contract holds) or lights up an error line (you just described something your data is not).
In production, the same job belongs to your platform's validator. For JavaScript and TypeScript, Ajv compiles schemas into fast validation functions and supports draft 2020-12 natively, with strict mode available when you want format assertions enforced. Python's jsonschema library validates the same drafts. .NET, Java, and Go each have mature implementations. The one piece of advice worth carrying into that work: pin the draft. Declare it with $schema on every file, match your validator version to it, and the specification's historical drift (definitions versus $defs, items versus prefixItems) stays a Wikipedia footnote instead of a production incident.
Frequently asked questions
These are the schema questions that come up the first time a team generates a contract: which draft comes out, why everything is required, and whether AI APIs accept the whole vocabulary. If yours is missing, the contact page takes new questions.
Which JSON Schema draft does this generator output?
Draft 2020-12, the most recent published revision of the specification. The output declares it via the $schema keyword: https://json-schema.org/draft/2020-12/schema. Draft 2020-12 is the version current validators target natively, and it is the closest thing JSON Schema has to a stable baseline; earlier drafts (07, 2019-09) still exist in the wild and use slightly different keywords.
Why does the generator mark every property as required?
Because your sample JSON contains every property, and a generator only knows what it saw. Marking observed properties required is the safe default for a contract: if the field was present in the example, downstream code probably depends on it. The correct fix is judgment you apply after generation (demote the optional fields to non-required by removing them from the required array, which stays valid either way), or flip the tool's 'No required list' toggle before copying for a documentation-style schema.
Can I validate my data against the schema right here?
Not on this page; the generator's job is the draft, and the validator's job belongs to your toolchain. Copy the schema out and run it through Ajv for JavaScript, jsonschema for Python, or the JSON Schema support in .NET and Java; all handle draft 2020-12. A schema you have never run against data is a hypothesis, not a contract.
Do AI APIs accept full JSON Schema?
They accept a subset. Structured-output and function-calling features across major LLM providers accept JSON Schema shapes (type, properties, required, enum, and array keywords) but ignore or reject keywords like $ref in some positions, additionalProperties handling varies, and each provider documents its own supported subset. Trim to the widely accepted core by hand (type, properties, required, enum, array keywords), and the golden rule is: test the schema against the provider, not against the specification.
Why did my number become type integer instead of number?
Because the sample value was 42, with no decimal point and no exponent. Inference maps JSON's number type by observation: a value like 42 becomes integer, a value like 19.5 becomes number. Both are valid JSON numbers, and if your API can send 42.0 some days, widen the type to number by hand after generating. A single sample is evidence, not proof, and this is the smallest of the places where that distinction shows.
Is my JSON uploaded to a server?
No. Parsing, inference, and schema generation run entirely in your browser. Your payload, which is quite often real customer data, never leaves the page: no upload, no history, no account. That architectural choice is standard across this site's data tools, and it matters most exactly here, where the input is so often a production sample.
Can I edit the schema after generating it?
Yes: copy it out and edit it in your own editor; that is the intended workflow. The generator produces a correct starting point, and the schema is plain JSON, so every validator-ready tweak is a text edit: tighten it (enum values, length bounds, patterns), loosen it (optional fields), or restructure it ($defs for shared shapes). Generation is the first draft, not the contract signing.
Sibling tools in the same toolbox
Schema generation sits in the middle of a small pipeline of JSON-shape tools, and the neighbors are worth knowing. The JSON to C# Class Converter turns the same payload into .NET types for the consuming side of an API. The JSON to TypeScript Interface does the same for the TypeScript world; as the comparison above explains, the interface and the schema are complementary artifacts, not substitutes. And before any of this works, the JSON Formatter & Validator is the tool that tells you the payload you copied was never valid JSON in the first place, usually with a more useful error message than your application logs.
Normative references
The specification is public, readable, and shorter than its reputation suggests, and the tool implements the current anchor draft plus the annotation vocabulary. These are the documents this generator was built against:
Sources and further reading
- JSON Schema Core: draft 2020-12, the normative specification(json-schema.org)
- Understanding JSON Schema: the community book(json-schema.org)
- JSON Schema: getting started, step by step(json-schema.org)
- Ajv: the reference JavaScript validator(ajv.js.org)
We cite primary sources (standards bodies, government agencies, official documentation) wherever they exist so you can verify every number on this page yourself.