JSON Schema Generator
JSON Input
Loading editor…
JSON Schema Output
Loading editor…

JSON Schema Generator

Paste any JSON document and get a valid JSON Schema (draft-07) generated instantly. The schema infers types, detects integers vs floats, handles nested objects and arrays, and marks all present keys as required.

Real-time
Schema updates as you type.
Draft-07
Outputs valid JSON Schema draft-07.
Nested
Handles deep objects and arrays.
Download
Save schema as schema.json.

What is JSON Schema?

JSON Schema is a vocabulary for describing the structure of JSON data. It lets you define what fields are expected, what types they should be, and which are required. Schemas are used for:

  • Validation — reject payloads that don't match the expected shape
  • Documentation — self-describing contracts for APIs
  • Code generation — tools like QuickType generate TypeScript types from JSON Schema
  • Form generation — libraries like react-jsonschema-form render UIs from schemas

A generated schema is a starting point — you'll usually refine it by adding constraints like minLength, minimum, enum, and format.

Anatomy of a JSON Schema

Here is a simple JSON document and the schema this tool generates from it:

Input JSON:

{
  "id": 1,
  "name": "Alice",
  "email": "alice@example.com",
  "active": true,
  "roles": ["admin", "editor"]
}

Generated Schema:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "id":     { "type": "integer" },
    "name":   { "type": "string" },
    "email":  { "type": "string" },
    "active": { "type": "boolean" },
    "roles":  { "type": "array", "items": { "type": "string" } }
  },
  "required": ["id", "name", "email", "active", "roles"]
}

Key fields:

  • $schema — declares which draft of the spec this schema follows
  • type — the JSON type: object, array, string, number, integer, boolean, null
  • properties — defines the schema for each key in an object
  • required — lists keys that must be present for the document to be valid
  • items — defines the schema for elements inside an array

Refining Your Schema — Useful Keywords

The generated schema captures types and structure. Most real schemas also need constraints.

String constraints:

{ "type": "string", "minLength": 1, "maxLength": 255 }
{ "type": "string", "format": "email" }
{ "type": "string", "format": "date-time" }
{ "type": "string", "pattern": "^[A-Z]{2}[0-9]{6}$" }

Number constraints:

{ "type": "integer", "minimum": 1, "maximum": 100 }
{ "type": "number",  "exclusiveMinimum": 0 }

Enum — restrict to a fixed set of values:

{ "type": "string", "enum": ["admin", "editor", "viewer"] }

To make a field optional, remove it from the required array. A field absent from required may be missing; if present, it must still match its schema.

Nullable fields use a type array:

{ "type": ["string", "null"] }

Common format values: email, uri, date, date-time, time, uuid, ipv4, ipv6.

Where JSON Schema Is Used

AJV is the dominant JSON Schema validator for Node.js — used by hundreds of thousands of packages:

const Ajv = require("ajv");
const ajv = new Ajv();
const valid = ajv.validate(schema, data);

FastAPI (Python) uses Pydantic models internally. Pydantic generates JSON Schema automatically, which FastAPI exposes as the OpenAPI documentation for every endpoint.

OpenAPI 3.x uses a JSON Schema subset to define request bodies, response payloads, and query parameters. The schema behind every Swagger UI you've seen is JSON Schema.

VS Code resolves JSON Schema for thousands of config files — package.json, tsconfig.json, .eslintrc — from the SchemaStore. That's where the IntelliSense and inline validation comes from.

Libraries like react-jsonschema-form and jsonforms render complete forms directly from a JSON Schema: inputs, labels, validation, conditionals — no custom UI code required.

Frequently Asked Questions

What version of JSON Schema does this generate?

The generator outputs JSON Schema draft-07, which is the most widely supported version and compatible with tools like AJV, Postman, and VS Code. Draft-07 is still the de-facto standard for most tooling even though newer drafts (2019-09, 2020-12) exist.

What is the difference between draft-07 and draft-2020-12?

Draft-2020-12 is the latest version and introduces features like $dynamicRef, prefixItems for tuple validation, and unevaluatedProperties. However, tooling support is still catching up — AJV requires explicit configuration for 2020-12, and many platforms still only support draft-07. Use draft-07 unless you have a specific reason to upgrade.

How are arrays handled?

If all items in an array have the same type, the items schema reflects that type. If items have mixed types, the generator uses oneOf to capture each distinct schema.

Are all fields marked as required?

Yes. Every key present in the sample JSON is added to the required array. Since the generator infers from a single sample, it has no way to know which fields are optional — remove keys from required that may be absent in real data.

What is the difference between integer and number in JSON Schema?

JSON Schema distinguishes between integer (whole numbers like 1, 42) and number (any numeric value including decimals like 3.14). The generator automatically uses integer for whole number values.

Can I use the generated schema to validate JSON?

Yes. Copy the schema and use it with any JSON Schema validator such as AJV (JavaScript), jsonschema (Python), or built-in validators in Postman and VS Code.

Can I generate TypeScript types from JSON Schema?

Yes. Tools like QuickType (quicktype.io) and json-schema-to-typescript (npm) take a JSON Schema and output TypeScript interfaces. This is a common workflow: sample JSON → JSON Schema (here) → TypeScript types.

Is my JSON data uploaded anywhere?

No. Schema generation runs in the browser. Nothing is transmitted — the page works offline once loaded.

More Tools