JSON Schema Validator Online

Validate any JSON document against a JSON Schema instantly. Paste your schema and your JSON data to check conformance, identify missing fields, and catch type errors. Free, no signup, supports draft-07 and later.

Open JSON Schema Validator →

What is JSON Schema?

JSON Schema is a vocabulary for annotating and validating JSON documents. A schema is itself a JSON document that describes the expected structure of another JSON value. It specifies what properties an object must have, what data types are allowed, which fields are required, what patterns strings must match, and the valid ranges for numeric values.

A minimal JSON Schema looks like this:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id":    { "type": "integer" },
    "name":  { "type": "string", "minLength": 1 },
    "email": { "type": "string", "format": "email" },
    "age":   { "type": "integer", "minimum": 0, "maximum": 150 },
    "roles": { "type": "array", "items": { "type": "string" } }
  },
  "required": ["id", "name", "email"]
}

This schema requires a JSON object with integer id, non-empty string name, and valid email string. The age and roles fields are optional. Any JSON that violates these constraints will fail validation with a descriptive error message.

JSON Schema is used across the software industry for API contract validation, configuration file validation, database schema enforcement, form input validation, and automated testing pipelines.

JSON Schema Draft Versions

JSON Schema has evolved through several specification drafts. Each version added new keywords and refined existing behavior. Here is an overview of the major versions:

Version $schema URI Key Changes
Draft-04draft-04/schemaIntroduced allOf, anyOf, oneOf, not
Draft-06draft-06/schemaAdded const, contains, propertyNames, examples
Draft-07draft-07/schemaAdded if/then/else, readOnly, writeOnly
2019-092019-09/schemaAdded $anchor, $recursiveRef, unevaluatedProperties
2020-122020-12/schemaprefixItems for tuples, $dynamicRef, stable spec

For maximum compatibility with existing tooling and libraries, draft-07 is the most widely supported version. For new projects, 2020-12 is the current recommended standard.

Key JSON Schema Keywords Explained

type

Specifies the allowed JSON type for a value. Valid types are string, number, integer, boolean, array, object, and null. You can pass an array of types to allow multiple: "type": ["string", "null"] accepts either a string or null.

required

An array of property names that must be present in the object. If any listed property is absent, validation fails. Note that required only checks for presence - it does not constrain the value. A property can be required but also have "type": "null", meaning it must be present but can be null.

properties

Defines schemas for named properties of an object. Each key in properties is a property name and each value is a sub-schema that the corresponding value must satisfy. Properties not listed under properties are allowed by default (unless additionalProperties: false is set).

pattern

Constrains a string value to match a regular expression. For example, "pattern": "^[A-Z]{2}[0-9]{4}$" would accept "AB1234" but reject "ab1234" or "ABC123". The pattern is matched against the entire string using the ECMAScript regular expression dialect.

Numeric constraints

For numbers and integers, you can apply minimum, maximum, exclusiveMinimum, exclusiveMaximum, and multipleOf. For example, "minimum": 1, "maximum": 100, "multipleOf": 5 accepts 5, 10, 15... up to 100.

Combining schemas with allOf, anyOf, oneOf

allOf requires the data to be valid against all listed sub-schemas (logical AND). anyOf requires validity against at least one (logical OR). oneOf requires validity against exactly one (exclusive OR). These keywords are powerful for modeling union types, inheritance, and polymorphic data structures.

Use Cases for JSON Schema Validation

API contract validation

REST APIs return JSON responses. Adding a JSON Schema to your API documentation (via OpenAPI / Swagger) lets clients and servers automatically validate request and response bodies against a contract. This catches integration bugs early and generates useful error messages when a client sends malformed data.

Configuration file validation

Application configuration files in JSON format can be validated against a schema at startup. If a required field is missing or a value has the wrong type, the application can emit a clear error message rather than failing silently at runtime hours later. VS Code uses JSON Schema to provide auto-complete and validation for tsconfig.json, package.json, and other config files.

Data pipeline validation

ETL (extract-transform-load) pipelines that process JSON data can use schema validation as a quality gate. Records that fail validation can be routed to an error queue for manual review rather than silently corrupting the downstream database. This is a critical pattern in data engineering and event-driven architectures.

Form and user input validation

Libraries like ajv (JavaScript), jsonschema (Python), and everit-json-schema (Java) can run JSON Schema validation on user-submitted form data server-side, providing structured validation error messages that map directly back to the form fields that failed.

Frequently Asked Questions

What is JSON Schema?

JSON Schema is a vocabulary for annotating and validating JSON documents. It is defined as a JSON document itself. A schema describes the expected structure of a JSON value: what properties it must have, what types those properties should be, which fields are required, what patterns strings must match, and more. JSON Schema is used for API contract validation, configuration file validation, and automated data quality checks.

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

Draft-07 (2018) is the most widely supported version across libraries and tools. Draft 2019-09 added anchors, $recursiveRef, and richer annotation support. Draft 2020-12 is the current stable specification and introduces prefixItems for array tuple validation, $dynamicRef replacing $recursiveRef, and other refinements. For maximum library compatibility, draft-07 is the safest choice. For new projects using modern validators like ajv 8+, 2020-12 is recommended.

How do I make a field required in JSON Schema?

Use the required keyword at the object level. It takes an array of property names that must be present. For example: {"type":"object","properties":{"name":{"type":"string"},"age":{"type":"integer"}},"required":["name"]}. This makes name required but leaves age optional. Omitting the required keyword entirely means all properties are optional.

Can I validate an array of objects with JSON Schema?

Yes. Use "type": "array" with the items keyword to define the schema for each array element. For example: {"type":"array","items":{"type":"object","required":["id","name"]}} validates an array where every element must be an object with both id and name. Add minItems and maxItems to constrain the array length.

Ready to validate your JSON against a schema?

Free, instant, 100% private. No account needed.

Open JSON Schema Validator →

Also useful: JWT Decoder | JSON Validator | JSON Formatter | JSONPath Evaluator | JSON Schema Tutorial | JSON to TypeScript