JSON Schema Generator
Paste a JSON sample and instantly get a clean JSON Schema. Supports draft 2020-12, 2019-09, and draft-07 with automatic format detection and live preview.
JSON Input
Generated Schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Root",
"type": "object",
"required": [
"id",
"name",
"email",
"age",
"isActive",
"createdAt",
"website",
"roles",
"address",
"posts"
],
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"name": {
"type": "string"
},
"email": {
"type": "string",
"format": "email"
},
"age": {
"type": "integer"
},
"isActive": {
"type": "boolean"
},
"createdAt": {
"type": "string",
"format": "date-time"
},
"website": {
"type": "string",
"format": "uri"
},
"roles": {
"type": "array",
"items": {
"type": "string"
}
},
"address": {
"type": "object",
"required": [
"street",
"city",
"zipCode"
],
"properties": {
"street": {
"type": "string"
},
"city": {
"type": "string"
},
"zipCode": {
"type": "string"
}
}
},
"posts": {
"type": "array",
"items": {
"type": "object",
"required": [
"title",
"views",
"published"
],
"properties": {
"title": {
"type": "string"
},
"views": {
"type": "integer"
},
"published": {
"type": "boolean"
}
}
}
}
}
}Options
About JSON Schema Generator
The JSON Schema Generator turns a raw JSON sample into a valid JSON Schema document in seconds. Instead of hand-writing types, required arrays, and nested definitions, you paste an example of the JSON you want to validate and the tool infers the structure, types, and common formats for you.
It supports the three most widely used draft versions — 2020-12, 2019-09, and Draft-07 — and runs entirely in your browser. Your JSON never leaves your device. You can tweak output options (title, description, required mode, format detection, strict objects, examples) and instantly copy or download the result as schema.json ready to use with Ajv, ajv-cli, OpenAPI, or IDE integrations.
How to Use JSON Schema Generator
- Paste a representative JSON sample into the JSON Input box on the left. You can start with the built-in Sample button.
- Pick the Draft Version your target tooling expects (Draft-07 has the widest compatibility).
- Set an optional Title and Description to document the schema.
- Choose how to treat required fields — mark every observed key as required, or leave the required array empty.
- Enable Detect formats to add format hints like
date-time,email, oruuidon strings that match known patterns. - Toggle Strict objects to add
additionalProperties: false, which rejects any keys not listed in your schema. - Click Copy or Download to export
schema.json. Use it directly with Ajv, OpenAPI, or IDE tooling. - Review and tighten the schema — add
minLength,enum,pattern, orminimum/maximumconstraints as needed.
Common Use Cases
API Request Validation
Generate schemas from example payloads and validate incoming JSON at your API gateway or server.
Form Validation
Use the schema with libraries like Ajv or Zod-from-JSON-Schema for consistent client + server validation.
Config File Checks
Validate app.config.json, manifest.json, or deployment files against a strict schema in CI.
OpenAPI & Swagger
Paste an example response body to quickly scaffold schema components for your API spec.
Data Contracts
Lock in the shape of messages between services, queues, or microservices with a shared schema.
Editor IntelliSense
Point VSCode or JetBrains IDEs at a $schema to get autocomplete and inline documentation for JSON files.
Frequently Asked Questions
What is JSON Schema?
JSON Schema is a vocabulary for describing the structure of JSON data. It defines required fields, property types, formats, and constraints in a machine-readable way so tools can validate documents automatically.
Which draft versions are supported?
This generator supports the three most widely used drafts: 2020-12, 2019-09, and Draft-07. Draft-07 has the broadest tooling compatibility; 2020-12 is the latest official draft.
How accurate is the schema inference?
The generator produces a starting schema based on your sample JSON. It infers types, detects common formats (date-time, email, uuid, uri, ipv4), merges object/array shapes, and marks all observed keys as required by default. Review and tighten it before production use — add constraints like minLength, pattern, enum, minimum/maximum as needed.
What does "All fields required" do?
When enabled, every key observed in your sample input is added to the required array on its parent object. Switch to "None" if your JSON has optional fields and you want to start with a more permissive schema.
Is my JSON sent to any server?
No. Every step — parsing, inference, formatting — runs in your browser. Your data never leaves your device.
How are arrays with mixed types handled?
If array items all share the same object shape, properties are merged intelligently and only the keys present in every item stay in required. If items have different primitive types or structures, the generator emits an anyOf schema so either form validates.
Can I use the output with Ajv?
Yes. Save the output as schema.json and run ajv validate -s schema.json -d data.json. It also works with ajv-cli, ajv-formats, Zod JSON-Schema converters, and most JSON Schema validators.
Why does my schema include $schema at the top?
The $schema keyword tells validators which draft your schema uses. Most tools require it for version-specific features like prefixItems (2020-12) or dependentRequired (2019-09).