Reference Knowledge Base

What is JSON Schema? The Complete Guide

What JSON Schema is: the definition, Draft-07 keywords (type, required, properties, format), how validation works, and how to generate a schema automatically.

JSON Schema is a vocabulary for annotating and validating JSON documents, defined by the json-schema.org specification. Draft-07 is the most widely supported version, used by OpenAPI, Swagger, Ajv, and Postman to validate API payloads against expected data types and formats.

JSON Schema Definition

JSON Schema is a declarative specification language for describing the structure and validation constraints of JSON documents. A JSON Schema is itself a valid JSON document that uses reserved keywords like type, properties, required, and format.

Key JSON Schema Keywords (Draft-07)

  • type — Value type: string, number, integer, boolean, array, object, null.
  • properties — Defines the expected keys and their schemas for an object.
  • required — Array of property names that must be present.
  • format — Semantic format: "date-time", "email", "uuid", "uri".
  • enum — Restricts the value to a specific set of allowed values.
  • minimum / maximum — Numeric range constraints.
  • minLength / maxLength — String length constraints.
  • pattern — Regular expression constraint for strings.
  • items — Schema for array elements.
  • $ref — Reference to another schema definition.

Common Validators Supporting JSON Schema

Ajv (JavaScript), jsonschema (Python), Jackson (Java), Newtonsoft (C#), OpenAPI/Swagger (all languages).

json
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "title": "User",
  "required": ["id", "email", "name"],
  "properties": {
    "id": {
      "type": "integer",
      "minimum": 1
    },
    "email": {
      "type": "string",
      "format": "email"
    },
    "name": {
      "type": "string",
      "minLength": 2,
      "maxLength": 100
    },
    "role": {
      "type": "string",
      "enum": ["admin", "editor", "viewer"]
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    }
  }
}

Try the free JSON Schema Generator

Runs entirely in your browser — no upload, no signup, and your data never leaves your device.

Open JSON Schema Generator

Frequently Asked Questions

What is JSON Schema used for?

JSON Schema is used to validate API request and response payloads, generate documentation, auto-generate TypeScript types, and define OpenAPI component schemas.

What is the difference between JSON Schema Draft-07 and Draft 2020-12?

Draft 2020-12 is newer and adds features like unevaluatedProperties and dynamic references. Draft-07 remains the most widely supported version in tooling.

How do I generate a JSON Schema automatically?

Use our free JSON Schema Generator at json2x.com/tools/json-schema-generator — paste any JSON payload and get a Draft-07 schema instantly.

Related JSON Topics & Reference Articles