ToolDeck

JSON Schema Validator

Validate JSON data against a JSON Schema (Draft 7)

Try an example

JSON Data

JSON Schema

Runs locally · Safe to paste secrets
Runs locally · Safe to paste secrets

What is JSON Schema Validation?

JSON Schema validation is the process of checking whether a JSON document conforms to a set of structural and value constraints defined in a JSON Schema. The schema itself is a JSON document that describes the expected shape of your data: which properties are required, what types they must be, the allowed ranges for numbers, string patterns, array lengths, and more. The JSON Schema specification is maintained at json-schema.org and published as a series of IETF drafts, Draft 7 and Draft 2020-12 are the most widely adopted.

Where plain JSON validation only checks syntax (are the brackets matched? are strings quoted?), schema validation goes further. It answers questions like: does the response from this API contain an "id" field that is always an integer? Is the "status" field one of three allowed values? Are nested objects shaped correctly? This kind of structural verification catches bugs that syntax checks miss entirely, because syntactically valid JSON can still be semantically wrong for your application.

JSON Schema is used in OpenAPI/Swagger definitions, configuration file validation, form validation, database document constraints, and automated testing. Tools like Ajv (JavaScript), jsonschema (Python), and check-jsonschema (CLI) implement the specification so you can validate data programmatically. This online validator lets you paste both a schema and a data document to check conformance instantly, without installing any library.

Why Use an Online JSON Schema Validator?

Writing schemas and debugging validation errors by hand is slow. An online JSON Schema validator gives you instant feedback on whether your data matches your schema, with clear error messages pointing to the exact property that failed.

Instant validation feedback
Paste your schema and data, and see validation results in real time. Each error shows the JSON path and the specific constraint that failed, so you can fix problems without reading through validator library output.
🔒
Privacy-first, browser-only processing
Your JSON data never leaves your browser. All validation runs locally in JavaScript. No server, no logs, no data retention. Safe for schemas that describe internal APIs or contain proprietary field names.
🎯
Draft-aware validation
The validator handles Draft 7 schema keywords including type, required, properties, enum, pattern, minimum/maximum, items, anyOf, oneOf, allOf, and additionalProperties. Test your schema here before wiring it into your build pipeline or test suite.
📋
No account or installation
Open the page, paste your JSON, and validate. No npm install, no pip package, no Docker image. Useful when you need a quick schema check on a machine where you cannot install development tools.

JSON Schema Validation Use Cases

API contract testing
Validate API responses against the schema defined in your OpenAPI spec. Catch breaking changes, like a field switching from integer to string, before they reach production.
Configuration file verification
Check that JSON config files for CI/CD pipelines, Kubernetes manifests, or application settings match the expected schema before committing. Prevents deployment failures caused by missing or mistyped keys.
DevOps pipeline gates
Add schema validation as a CI step to reject payloads that violate the contract. This works for Terraform variable files, GitHub Actions inputs, or any structured JSON consumed by automation.
QA and test data review
Verify that test fixtures and mock data files conform to the same schema your application expects. Mismatched test data is a common source of false-positive test results.
Data pipeline ingestion
Validate incoming JSON records at the edge of a data pipeline. Schema validation filters out malformed events before they reach your data warehouse, reducing cleanup costs downstream.
Learning JSON Schema syntax
Experiment with schema keywords interactively. Write a schema, paste test data, and see which constraints pass or fail. Faster than writing a script and running it from the terminal each time.

JSON Schema Keywords Reference

A JSON Schema is built from keywords that each impose a constraint on the validated data. The table below lists the most commonly used keywords in Draft 7 and later. Every keyword can be combined with others in the same schema object.

KeywordPurposeExample
typeRestricts the data type"type": "string"
propertiesDefines expected object keys and their schemas"properties": { "name": { "type": "string" } }
requiredLists mandatory properties"required": ["id", "name"]
itemsSchema for array elements"items": { "type": "number" }
enumRestricts value to a fixed set"enum": ["active", "inactive"]
patternRegex constraint on strings"pattern": "^[A-Z]{2}\\d{4}$"
minimum / maximumNumeric range bounds"minimum": 0, "maximum": 100
minLength / maxLengthString length bounds"minLength": 1, "maxLength": 255
$refReuses another schema by URI"$ref": "#/$defs/address"
additionalPropertiesControls extra keys in objects"additionalProperties": false
anyOf / oneOf / allOfCombines multiple schemas logically"anyOf": [{ "type": "string" }, { "type": "null" }]
if / then / elseConditional schema application"if": { "properties": { "type": { "const": "email" } } }

JSON Schema Draft Comparison: Draft 7 vs 2019-09 vs 2020-12

JSON Schema has gone through several draft versions. Draft 7 (published 2018) is the most widely supported in tooling. Draft 2019-09 introduced $defs (replacing definitions), unevaluatedProperties, and $recursiveRef. Draft 2020-12 (the latest stable release) replaced $recursiveRef with $dynamicRef and introduced prefixItems for tuple validation. When choosing a draft, check that your validation library supports it. Ajv supports all three drafts. Python's jsonschema library supports up to 2020-12 since version 4.0.

FeatureDraft 7Draft 2019-09Draft 2020-12
$schema URIdraft-07/schema#2019-09/schema2020-12/schema
if / then / elseYesYesYes
$defs (definitions)definitions$defs$defs
$ref alongside keysNo (sibling ignored)YesYes
$dynamicRefNoNo ($recursiveRef)Yes
prefixItemsNo (use items array)No (use items array)Yes
unevaluatedPropertiesNoYesYes
$vocabularyNoYesYes

Code Examples

These examples show how to validate JSON against a schema programmatically. Each uses a well-maintained library for its language ecosystem.

JavaScript (Ajv)
import Ajv from 'ajv';

const ajv = new Ajv();

const schema = {
  type: 'object',
  properties: {
    name: { type: 'string', minLength: 1 },
    age: { type: 'integer', minimum: 0 },
    email: { type: 'string', format: 'email' }
  },
  required: ['name', 'email'],
  additionalProperties: false
};

const data = { name: 'Alice', age: 30, email: 'alice@example.com' };

const validate = ajv.compile(schema);
const valid = validate(data);
console.log(valid);          // → true
console.log(validate.errors); // → null

// Invalid data — missing required "email"
validate({ name: 'Bob', age: 25 });
console.log(validate.errors);
// → [{ instancePath: '', keyword: 'required', params: { missingProperty: 'email' } }]
Python (jsonschema)
from jsonschema import validate, ValidationError

schema = {
    "type": "object",
    "properties": {
        "name": {"type": "string", "minLength": 1},
        "age": {"type": "integer", "minimum": 0},
        "tags": {
            "type": "array",
            "items": {"type": "string"},
            "uniqueItems": True
        }
    },
    "required": ["name"]
}

# Valid data
validate(instance={"name": "Alice", "age": 30, "tags": ["admin"]}, schema=schema)
# → No exception raised

# Invalid data — wrong type for "age"
try:
    validate(instance={"name": "Alice", "age": "thirty"}, schema=schema)
except ValidationError as e:
    print(e.message)
    # → 'thirty' is not of type 'integer'
    print(e.json_path)
    # → $.age
Go (santhosh-tekuri/jsonschema)
package main

import (
    "fmt"
    "strings"
    "github.com/santhosh-tekuri/jsonschema/v5"
)

func main() {
    schemaJSON := `{
        "type": "object",
        "properties": {
            "id": { "type": "integer" },
            "status": { "enum": ["active", "inactive"] }
        },
        "required": ["id", "status"]
    }`

    compiler := jsonschema.NewCompiler()
    compiler.AddResource("schema.json", strings.NewReader(schemaJSON))
    schema, _ := compiler.Compile("schema.json")

    // Valid data
    data := map[string]interface{}{"id": 1, "status": "active"}
    err := schema.Validate(data)
    fmt.Println(err) // → <nil>

    // Invalid — missing "status"
    bad := map[string]interface{}{"id": 2}
    err = schema.Validate(bad)
    fmt.Println(err) // → validation failed: missing properties: 'status'
}
CLI (check-jsonschema)
# Install via pip
pip install check-jsonschema

# Validate a file against a schema
check-jsonschema --schemafile schema.json data.json
# → ok -- validation done

# Validate against a remote schema (e.g., GitHub Actions workflow)
check-jsonschema --builtin-schema vendor.github-workflows my-workflow.yml

# Validate multiple files at once
check-jsonschema --schemafile schema.json file1.json file2.json file3.json

Frequently Asked Questions

What is the difference between JSON validation and JSON Schema validation?
JSON validation checks whether a string is valid JSON syntax: properly nested brackets, quoted keys, no trailing commas. JSON Schema validation goes a step further and checks whether the parsed JSON data matches a structural contract: correct types, required fields present, values within allowed ranges. You need valid JSON before you can apply a schema, but valid JSON can still fail schema validation.
Which JSON Schema draft should I use?
Draft 7 is the safest default. It has the widest library support across languages and covers the keywords most projects need: type, properties, required, enum, pattern, anyOf, oneOf, allOf, and $ref. Use Draft 2020-12 if you need features like prefixItems for tuple validation, $dynamicRef for extensible schemas, or unevaluatedProperties for strict object shapes. Check your validator library's documentation to confirm draft support before upgrading.
How does $ref work in JSON Schema?
The $ref keyword lets you reference another schema by URI instead of duplicating it. A value like "$ref": "#/$defs/address" points to a schema defined in the $defs section of the same document. You can also reference external files with "$ref": "https://example.com/schemas/address.json". In Draft 7, $ref replaces all sibling keywords in the same object. In Draft 2019-09 and later, sibling keywords are applied alongside $ref.
What is the difference between anyOf, oneOf, and allOf?
allOf requires the data to match every sub-schema in the array. anyOf requires a match against at least one sub-schema. oneOf requires a match against exactly one sub-schema and fails if the data matches zero or more than one. For nullable fields, anyOf with a type and null is common: {"anyOf": [{"type": "string"}, {"type": "null"}]}. Use oneOf when sub-schemas are mutually exclusive, like tagged unions.
Can JSON Schema validate nested objects and arrays?
Yes. Use the properties keyword to define schemas for nested object keys, and the items keyword to define a schema that every array element must match. You can nest these to any depth. For arrays where each position has a different schema (tuples), use prefixItems in Draft 2020-12 or the array form of items in Draft 7.
Is the data I paste into this tool sent to a server?
No. The validator runs entirely in your browser using JavaScript. Your JSON data and schema are never transmitted to any server. You can verify this by opening your browser's network inspector while using the tool.
How do I validate JSON Schema in a CI/CD pipeline?
Use a CLI validator like check-jsonschema (Python/pip) or ajv-cli (Node.js/npm). Both accept a schema file and one or more data files as arguments. Add the validation command as a step in your CI config. If validation fails, the process exits with a non-zero code, which blocks the pipeline. For GitHub Actions, you can also use the check-jsonschema action directly.