What is a JSON Schema generator?
A JSON Schema generator takes a sample JSON document and produces a JSON Schema: a standard, machine-readable contract describing that JSON's structure: the type of every field, which fields are required, how objects nest, and what arrays contain. Writing that schema by hand from a real API response is slow and error-prone. Paste the sample here and the schema is inferred for you: nested objects become reusable named $ref definitions, arrays get typed items, and present fields are marked required. It runs quicktype's inference engine 100% in your browser, so payloads with tokens or personal data never leave your machine.
What you can do with the generated schema
- Validate payloads: feed the schema to a validator like Ajv to check that other JSON matches the expected shape.
- Document / contract-test an API: you have a real response but need a schema for OpenAPI or contract tests.
- Drive tooling: many libraries generate types, forms, or fake data from a JSON Schema.
Generate vs. validate
This page generates a schema from example JSON. Two related jobs are separate tools: to check that a document is well-formed JSON at all (with the exact line and column of any error), use the JSON Validator; to validate a document against a JSON Schema, paste the schema this tool produces into the JSON Schema Validator (powered by Ajv). Need typed code instead of a schema? The JSON to TypeScript and other code generators use the same inference engine.
How to use
- Paste a JSON sample (an API response works well) into the Input pane.
- A JSON Schema is generated instantly: types are inferred, present fields become
required, and each nested object is lifted into its own named$refdefinition. - Non-standard JSON (single quotes, trailing commas, comments) is auto-repaired first.
- Copy or download the schema and use it to validate other payloads (e.g. with Ajv), document an API, or drive codegen.
Examples
JSON sample → JSON Schema
{
"id": 42,
"name": "Ada",
"tags": ["admin", "editor"]
}{
"$schema": "http://json-schema.org/draft-06/schema#",
"$ref": "#/definitions/Root",
"definitions": {
"Root": {
"type": "object",
"additionalProperties": false,
"properties": {
"id": { "type": "integer" },
"name": { "type": "string" },
"tags": { "type": "array", "items": { "type": "string" } }
},
"required": ["id", "name", "tags"],
"title": "Root"
}
}
}Nested objects become named definitions
{ "owner": { "email": "[email protected]", "active": true } }"owner": { "$ref": "#/definitions/Owner" }
…
"Owner": {
"type": "object",
"properties": {
"email": { "type": "string" },
"active": { "type": "boolean" }
},
"required": ["active", "email"]
}FAQ
What is a JSON Schema generator?
It turns a sample JSON document into a JSON Schema: a standard, machine-readable description of that JSON's shape (types, required fields, nested structure, array item types). Instead of hand-writing the schema, you paste an example and get one back, entirely in your browser.
How do I generate a JSON Schema from JSON?
Paste any JSON sample into the Input pane. The schema is inferred from the values and nesting and appears instantly. Nothing is uploaded. Check DevTools: zero network requests.
Which JSON Schema draft does it output?
Draft-06 (http://json-schema.org/draft-06/schema#). It uses definitions with $ref so each distinct nested object becomes a reusable named type, plus required arrays and additionalProperties: false.
How are nested objects and arrays handled?
Each distinct nested object is lifted into its own named definition and referenced with $ref. Arrays become {"type": "array", "items": …} with the item type inferred from the elements.
Should I paste one sample or many?
Paste an array of objects to infer from the union of all items; that catches optional fields a single sample would miss. Fields absent from some items are simply omitted from required.
Can it validate JSON against a schema too?
This tool generates a schema. To validate a document against a schema, feed the generated schema to a validator such as Ajv. To check that JSON is well-formed at all, use the JSON Validator.