logo
GeekFormat

JSON Schema Validator

Free online JSON Schema validator supporting all major specifications: Draft 4, 6, 7, 2019-09, and 2020-12. Real-time millisecond validation, precise JSON Pointer error location, detailed field-level error explanations, with support for $ref resolution, if/then/else conditional validation, anyOf/oneOf/allOf combinatorial logic and more. No registration, no uploads - runs entirely in your browser locally, your data never leaves your device.

Related

Use Cases

  • API development: Validate backend JSON responses against OpenAPI/Swagger Schema definitions
  • Frontend form validation: Validate user input data against JSON Schema before submission
  • Configuration validation: Verify JSON config files (package.json, tsconfig.json, CI configs, etc.)
  • API debugging: Validate request and response bodies against agreed formats during third-party API integration
  • Teaching & learning: Experiment and validate Schema syntax while learning JSON Schema
  • Test case writing: Manually validate Schema rule effects before integrating into test code
  • Data quality checks: Validate imported JSON data structure during ETL processes to catch dirty data early
  • Team collaboration: After agreeing on Schema between frontend and backend, verify both implementations match

Features

  • Full version support: Complete support for JSON Schema Draft 4/6/7/2019-09/2020-12, auto-detects $schema declaration
  • Real-time validation: Validate as you type with millisecond response, no button click needed
  • Precise error location: Uses standard JSON Pointer paths to pinpoint exact failing fields, click errors to jump
  • Detailed error messages: Every error includes friendly explanations and trigger reasons to help fix issues quickly
  • Advanced validation: Supports local $ref resolution, if/then/else conditional validation, anyOf/oneOf/allOf combinatorial logic
  • Responsive design: Desktop dual-pane layout, mobile auto single-pane, with split ratio adjustment support
  • Quick operations: One-click format/minify/clear/copy, built-in user/product/config sample templates
  • Privacy & security: All validation runs entirely in your browser, JSON data and Schema never uploaded
  • Keywords cheat sheet: Built-in JSON Schema keywords reference table organized by category
  • Version comparison: Draft 4 through 2020-12 version differences comparison table

How to Use

  1. Enter or paste Schema: Input your JSON Schema definition in the left editor, or click 'Load Sample' for preset templates
  2. Enter data to validate: Input the JSON data to validate in the right editor (page loads with sample data by default)
  3. Select specification version: Choose Draft version in toolbar (auto-detects $schema declaration by default)
  4. View validation results: Real-time automatic validation shows green 'Valid' on success, specific error paths and reasons on failure
  5. Fix errors: Click error list items to quickly locate errors, fix issues and revalidate in real-time

FAQ

How do I validate JSON data with JSON Schema?

First write your JSON Schema rules in the left editor (defining field types, required fields, value ranges, etc.), then input the JSON data to validate in the right editor. The tool automatically performs real-time validation and displays results. Valid data shows a green success prompt; invalid data lists all errors with their JSON Pointer paths. The page loads a user info sample by default, which you can reference when writing your own Schema.

What validation rules does JSON Schema support?

JSON Schema supports rich validation rules: type checking (type), required fields (required), enum values (enum/const), string length and regex matching (minLength/maxLength/pattern), numeric ranges (minimum/maximum/multipleOf), semantic formats (format: email/uri/date-time/uuid/ipv4 etc.), array length and item constraints (minItems/maxItems/uniqueItems/items), object property constraints (properties/additionalProperties/propertyNames), logical combinations (allOf/anyOf/oneOf/not), conditional validation (if/then/else), and reference reuse ($ref/$defs). The 'JSON Schema Keywords Cheat Sheet' below lists all common keywords with examples.

What's the difference between anyOf, oneOf, and allOf?

allOf means data must match all sub-schemas (logical AND, commonly used for schema inheritance/extension); anyOf means data passes if it matches at least one sub-schema (logical OR, allows multiple matches); oneOf means data must match exactly one sub-schema (XOR, precisely one match). For example, use anyOf when a field can be either string or number; use oneOf when auth type must be exactly one of bearer or basic.

Does it support $ref references and shared definitions?

Yes. The tool resolves local references including $ref: '#/$defs/xxx' form definition reuse (Draft 2019-09+ uses $defs, older specs use definitions), and references to other paths within the same file. You can define reusable sub-structures in $defs and reference them in multiple places. Note: External remote references (cross-URL $ref) are not automatically resolved for security reasons.

What's the difference between JSON Schema validation and JSON formatting?

JSON formatting (also called JSON beautify/minify) only changes JSON indentation/layout to make it more readable or compact, without checking content validity. JSON Schema validation checks whether JSON data content matches your defined rules (types, ranges, required fields, etc.) - this is content validation. JSON syntax errors (extra commas, mismatched quotes) are basic errors; Schema validation includes syntax checking but goes far beyond - it also validates business-rule level legitimacy.

Which JSON Schema specification versions are supported?

The tool supports all five major versions: JSON Schema Draft 4, Draft 6, Draft 7, Draft 2019-09, and Draft 2020-12. By default it auto-detects the version from the $schema field in your Schema; you can also manually switch versions in the toolbar for testing. Draft 7 is currently the most widely used version; Draft 2020-12 is the latest stable version. The 'Version Comparison Table' below lists functional differences between versions.

Can error reports locate specific field positions?

Yes. Every validation error provides a standard JSON Pointer path (e.g., /user/address/city or /items/0/name) precisely indicating the failing field location. Clicking an error in the error list auto-scrolls the editor to that location. JSON Pointer uses RFC 6901 standard with slash-separated segments and zero-based array indices.

How do I use JSON Schema required?

required is a string array placed at the object level schema, listing which properties are required. For example: "type": "object", "properties": { "id": {"type": "string"}, "name": {"type": "string"} }, "required": ["id", "name"] means id and name fields must exist. Note: required goes in the parent object level, not inside each property's schema - this is the most common beginner mistake.

How do I write JSON Schema pattern regex?

The pattern keyword is for string types; its value is a regular expression string (following ECMA-262 regex syntax), and the string must match this pattern to pass. For example "pattern": "^[a-zA-Z0-9_]{3,16}$" validates usernames, "pattern": "^1[3-9]\d{9}$" validates Chinese mobile phone numbers. Note: regex patterns don't need surrounding slashes /, just write the pattern content directly; backslashes in JSON need to be double-escaped.

What's the difference between JSON Schema enum and const?

enum accepts an array of values; data must be exactly one value from the array, e.g., "enum": ["admin", "user", "guest"] means role can only be one of these three values. const accepts a single fixed value; data must strictly equal this value, e.g., "const": "bearer" means auth type can only be bearer. If an enum has only one value, use const instead for clearer semantics.

How do I use JSON Schema additionalProperties?

additionalProperties controls whether objects allow extra properties not defined in properties. Set to false to disallow any extra properties (strict mode); set to true to allow any extra properties (default behavior); can also be set to a schema object that extra properties must conform to. For example "additionalProperties": { "type": "string" } means all extra field values must be strings. API development typically recommends false to avoid clients sending unexpected fields.

How do I write JSON Schema if/then/else conditional validation?

if/then/else implements conditional validation: when data matches the if schema, it must also satisfy the then schema; otherwise it must satisfy the else schema (else is optional). Typical scenario: when type field is "business", require businessLicense field; when type is "personal", don't require it. Example: "if": { "properties": { "type": { "const": "business" } }, "required": ["type"] }, "then": { "required": ["businessLicense"] }

What formats does JSON Schema format support?

The format keyword provides semantic format validation. Common values include: date-time (ISO 8601 datetime), date (date YYYY-MM-DD), time (time HH:MM:SS), email (email address), uri (URI/URL), uuid (UUID), ipv4/ipv6 (IP address), hostname (hostname), regex (regular expression), etc. Note: In Draft 2019-09 and later, format defaults to annotation-only without forced validation; this tool enables format validation by default.

How do I validate API responses with JSON Schema?

Write a corresponding JSON Schema based on API documentation (or OpenAPI/Swagger definitions), then paste the actual API response JSON into the data area for validation. Typically you define the top-level response structure (e.g., code/message/data fields), specific structure of array elements in data, and type/constraints for each field. Use $defs to reuse repeated data structures (user info, pagination info, etc.).

How do I interpret JSON Schema errors?

Error messages contain three parts: (1) Path: JSON Pointer to the failing field; (2) Keyword: which validation keyword failed (required, type, minimum, pattern, etc.); (3) Message: specific failure reason. For example, error path /age, keyword minimum, message "must be >= 0" means the age field value is less than 0, violating minimum constraint. Clicking an error jumps directly to the corresponding code location.

What's the difference between JSON Schema and TypeScript types?

TypeScript types only check at compile time, don't exist at runtime, and cannot validate external input data (API request bodies, user input). JSON Schema is runtime data validation that can validate specific value ranges, regex matching, enum values, required fields, array lengths, and other fine-grained constraints that TypeScript cannot express. In practice, both are often combined: TypeScript for static type checking, JSON Schema (or JSON Schema-based validators like Ajv/Zod) for runtime data validation. Tools exist to convert between JSON Schema and TypeScript types.

What is JSON Schema Validation

JSON Schema validation is a technique for verifying that JSON data structure and content matches expected rules through declarative specifications. JSON Schema itself is a specification document written in JSON that defines what JSON data should look like: which fields exist, what types they are, what value ranges are allowed, which fields are required, whether additional properties are allowed, and more.

In frontend-backend separation development, API design, configuration validation, and data quality assurance, JSON Schema validation is an essential tool. It intercepts invalid data before it enters your system, preventing program exceptions caused by malformed data. With this tool, you can quickly verify that Schema definitions are correct, test that JSON data matches expectations, and catch data issues during development.

JSON Pointer is the path location syntax used in error reports, following RFC 6901 standard format with slash-separated path segments. For example, path /user/address/city refers to the city field under the address object under the user object at the root. Array elements use zero-based numeric indices, such as /items/2/name referring to the name field of the 3rd element (index 2) in the items array. Special characters (~ and /) are escaped as ~0 and ~1 respectively. Understanding JSON Pointer paths helps you quickly locate specific failing fields.

This tool supports all major JSON Schema versions from classic Draft 4 to latest Draft 2020-12, automatically detecting the $schema version declared in your Schema while allowing manual version switching for testing. The 'JSON Schema Keywords Cheat Sheet' below lists all common validation keywords with usage examples organized by category, and the 'Version Comparison Table' helps you understand functional differences between versions.

The JSON Schema format keyword provides semantic format validation. Common values include: date-time (ISO 8601 datetime), date (date YYYY-MM-DD), time (time HH:MM:SS), email (email address), uri (URI/URL), uuid (UUID), ipv4/ipv6 (IP address), hostname (hostname), regex (regular expression). Note that in Draft 2019-09 and later, format defaults to annotation-only without forced validation; this tool enables format validation by default.

JSON Schema Keywords Cheat Sheet

The table below lists the most commonly used validation keywords in the JSON Schema specification, organized by category for quick reference.

KeywordDescription
Basic Types
typeSpecify data type: string, number, integer, boolean, array, object, null. Supports single type or array of types.
Object Validation
propertiesDefine sub-schemas for object properties.
requiredString array specifying which properties are required.
additionalPropertiesControl whether extra properties not defined in properties are allowed; can be false or a schema.
propertyNamesSchema that property names must match (commonly uses pattern regex).
minPropertiesMinimum number of properties an object must contain.
maxPropertiesMaximum number of properties an object may contain.
Enums & Constants
enumArray of allowed values; data must be exactly one value from the array.
constConstant value; data must strictly equal this value.
Numeric Constraints
minimumMinimum numeric value (inclusive).
maximumMaximum numeric value (inclusive).
exclusiveMinimumValue must be strictly greater than (exclusive).
exclusiveMaximumValue must be strictly less than (exclusive).
multipleOfValue must be a multiple of the specified number.
String Constraints
minLengthMinimum string length.
maxLengthMaximum string length.
patternRegular expression; string must match this pattern.
formatSemantic format validation: email, uri, date-time, uuid, ipv4, ipv6, hostname, etc.
Array Constraints
itemsSchema for array elements (single schema applies to all elements).
minItemsMinimum number of array elements.
maxItemsMaximum number of array elements.
uniqueItemsWhether array elements must be unique.
containsAt least one array element must match this schema.
Combinatorial Logic
allOfData must match all sub-schemas (logical AND).
anyOfData must match at least one sub-schema (logical OR).
oneOfData must match exactly one sub-schema (XOR).
notData must NOT match this schema (logical NOT).
Conditional Validation
ifConditional schema; if data matches if, must satisfy then; otherwise must satisfy else.
thenSchema to satisfy when if condition holds.
elseSchema to satisfy when if condition does not hold.
References & Reuse
$refReference other schema definitions; supports local references (#/$defs/xxx) and remote references.
$defsDefine reusable sub-schemas (Draft 2019-09+; older versions use definitions).
definitionsKeyword for reusable sub-schemas in Draft 4-7.
Metadata
titleSchema title (annotation, not validated).
descriptionSchema description (annotation, not validated).
defaultDefault value (annotation, not validated).
examplesArray of example values (annotation, not validated).
$schemaSpecify JSON Schema specification version in use.
Dependencies
dependentRequiredProperty dependency: when a property exists, other properties must also exist (Draft 2019-09+).
dependenciesDependency keyword in Draft 4-7 covering both property and schema dependencies.

JSON Schema Version Comparison

JSON Schema has evolved through multiple Draft versions. Draft 7 is currently the most widely used version; Draft 2020-12 is the latest stable release.

FeatureDraft 4Draft 6Draft 72019-092020-12
type validation
required fields
enum/const✓ enum
minimum/maximum
exclusiveMinimum/Maximumbooleannumbernumbernumbernumber
multipleOf
minLength/maxLength
pattern regex
format validationannotation by defaultannotation by default
items array
contains
minItems/maxItems
uniqueItems
additionalProperties
propertyNames
allOf/anyOf/oneOf/not
if/then/else
$ref references
$defs reusedefinitionsdefinitionsdefinitions$defs$defs
dependentRequired
prefixItems tuplesarray formarray formarray formarray formprefixItems
unevaluatedProperties
$dynamicRef/$anchor✓ $recursiveRef✓ dynamicRef

Code Examples

JavaScript: Validate with Ajv library

javascript

Ajv (Another JSON Schema Validator) is the most popular and performant JSON Schema validation library in the JavaScript ecosystem, supporting Draft 04/06/07/2019-09/2020-12.

// Install: npm install ajv
const Ajv = require('ajv');
const ajv = new Ajv({ allErrors: true });

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

// Compile validation function
const validate = ajv.compile(schema);

// Validate data
const data = { name: 'John', email: 'john@example.com', age: 25 };
const valid = validate(data);

if (!valid) {
  console.log('Validation failed:', validate.errors);
} else {
  console.log('Validation passed!');
}

Python: Validate with jsonschema library

python

jsonschema is the most commonly used JSON Schema validation library in Python, installable via pip.

# Install: pip install jsonschema
import jsonschema
from jsonschema import validate

# Define Schema
schema = {
    "type": "object",
    "required": ["name", "email"],
    "properties": {
        "name": {"type": "string", "minLength": 1},
        "email": {"type": "string", "format": "email"},
        "age": {"type": "integer", "minimum": 0}
    },
    "additionalProperties": False
}

# Data to validate
data = {"name": "John", "email": "john@example.com", "age": 25}

try:
    validate(instance=data, schema=schema)
    print("Validation passed!")
except jsonschema.exceptions.ValidationError as e:
    print(f"Validation failed: {e.message}")
    print(f"Error path: {list(e.absolute_path)}")

Privacy & Security

All JSON data and schema validation runs entirely in your browser locally. Inputs are never uploaded to any server, nor stored, logged, or analyzed. Closing the page clears all data automatically — sensitive API contracts, business configs, and test data are safe to use.

Authoritative References

Troubleshooting

Unexpected token / Unexpected end of JSON input (JSON syntax error)

Check for extra commas (especially after the last property/element), whether quotes are paired, whether single quotes were used (JSON requires double quotes), and whether brackets match. You can first use a JSON formatter/repair tool to check syntax before Schema validation.

must have required property 'xxx' (missing required field)

Add the xxx field to your JSON data, or if the field is truly not required, remove it from the Schema's required array. Note: the required array goes at the object level, not inside properties.

must be string/number/boolean/array/object (type mismatch)

Check that the field's value type matches the type specified in the Schema. Common errors: numbers quoted as strings, booleans written as "true"/"false" strings, null written as "null" string.

must NOT have additional properties (disallowed extra properties present)

Either remove the extra fields from data, change additionalProperties to true in Schema (allow extra properties), or add definitions for those fields in properties. API development recommends false for strict mode.

must match pattern (string does not match regex)

Check that string format matches the regex rule specified in pattern. Note: backslashes in regex patterns in JSON need to be double-escaped, e.g., \d must be written as \\d in JSON. Regex patterns don't need surrounding slashes /.

must be equal to constant / must be equal to one of the allowed values (value not in enum range)

Check that the field value is one of the values in the enum array, or equals the const-specified constant. Case-sensitive, strings must match exactly.

must have at least/minimum/maximum N items (array length constraint violation)

Check that array element count satisfies minItems/maxItems limits. If uniqueItems error occurs, array has duplicate elements that need deduplication.

must be >= / <= / multipleOf (numeric range violation)

Check that numeric values fall within minimum/maximum specified ranges, and are multiples of multipleOf values. Note boundary values: exclusiveMinimum/exclusiveMaximum indicate exclusive bounds (strictly greater/less than).