JSON Schema Validator

Left: JSON data to check. Right: JSON Schema. Click Validate in the left footer; a one-line summary appears in the right footer (hover for full issue list).

Validating JSON with a schema

JSON Schema is a vocabulary for describing JSON documents: which properties exist, their types, allowed values, and nesting. Validation compares a parsed JSON instance against such a schema—not against “looks like JSON” syntax rules.

On this page the left editor holds the instance (payload), the right editor holds the schema JSON. Syntax must be valid on both sides before structural checks run; schema-side errors and match results appear in the right footer.

JSON Schema — background

Instance document vs schema document

The instance is your data: API body, config, message. The schema is another JSON document that uses keywords such as type, properties, required, items, enum, and format to constrain that data. Validators (here: Ajv) compile the schema, then test the instance keyword by keyword.

Common keywords you will see

type restricts values (object, array, string, number, integer, boolean, null). properties names fields on objects; required lists mandatory keys. items describes array elements. enum lists allowed literals; pattern applies a regex to strings. format adds semantic checks (email, date-time, uri) when both schema and validator support them.

Error paths (JSON Pointer)

Failures reference locations like /contact or /items/0/price. That is JSON Pointer syntax: /contact is a root property; /items/0 is the first array element. Pointers map directly to positions in the instance JSON, which is why they are used in APIs and OpenAPI examples.

Drafts: 07, 2019-09, 2020-12

The $schema URL declares which specification version the schema follows. Draft-07 is widely deployed; 2019-09 and 2020-12 add keywords such as unevaluatedProperties and adjusted $ref behavior. Validators must use the matching dialect—this page reads $schema and rejects unknown draft URLs.

Where validation fits

Contract before integration

OpenAPI and AsyncAPI often embed JSON Schema for request bodies. Checking a sample payload against that schema catches wrong types or missing required fields before you depend on a remote 400 response.

Stricter vs permissive schemas

additionalProperties: false rejects unknown keys; omitting it (draft-07 default) allows extras unless you tighten with unevaluatedProperties in newer drafts. Validation outcome reflects what your schema actually says—not an implicit “strict JSON” rule.

Frequently asked questions

What is JSON Schema validation?
It checks whether a JSON value satisfies constraints in a schema document: types, required fields, enums, string patterns, array bounds, nested objects, and optional format checks. It is separate from asking whether the text parses as JSON.
How do I validate JSON against a JSON Schema online?
Paste the instance on the left and the schema on the right, then click Validate. A pass means the instance satisfies every applicable keyword; failures list JSON Pointer paths and the rule that failed.
JSON syntax check vs JSON Schema—what is the difference?
Syntax validation only ensures quotes, commas, and brackets form legal JSON. JSON Schema validation runs on the parsed value. Fix syntax first (e.g. with JSON repair), then validate structure.
Which JSON Schema draft should my schema use?
Match your toolchain: OpenAPI 3.1 often uses 2020-12; older stacks use draft-07. Set $schema accordingly. If $schema is missing, many tools assume draft-07.
Why does every field look required in a generated schema?
Sample-based generators mark keys present in the sample as required. That is an inference limit, not a JSON Schema rule. Edit required arrays by hand or use the JSON Schema generator with multiple sample objects.
Are properties allowed if they are not listed in properties?
In draft-07, unlisted properties are allowed unless additionalProperties is false. In 2019/2020 you can also use unevaluatedProperties. Your schema defines policy; the validator reports violations of that policy only.
What does format email or date-time do?
format is an annotation that many validators implement as extra checks on strings. email checks rough address shape; date-time expects ISO 8601 strings. If the schema omits format, strings are only checked as type string.