What is a JSON Schema?

A JSON Schema describes what a JSON document should look like: which properties an object has, which of them are required, the type of each value, allowed ranges and lengths, patterns and formats such as email addresses or dates. APIs, configuration files and form builders use schemas to check data before they trust it, and OpenAPI describes request and response bodies with them.

How to use the validator

  1. Paste or type the JSON Schema in the first box.
  2. Paste or type the JSON data to check in the second box.
  3. The result appears as you type: either the JSON is valid, or every error is listed with the path of the value that fails, the schema keyword it breaks and a short explanation.
  4. Each failing value is marked in the data. Click an error to scroll the data to it, or click a mark to find its error in the list.

The Schema version field shows which draft of JSON Schema the data was checked against.

Which drafts it supports

The schema's $schema keyword picks the draft:

  • Draft 2020-12: https://json-schema.org/draft/2020-12/schema
  • Draft 2019-09: https://json-schema.org/draft/2019-09/schema
  • Draft 7: http://json-schema.org/draft-07/schema#
  • Draft 6: http://json-schema.org/draft-06/schema#

A schema without $schema is checked as draft 7. Draft 4 and older aren't supported. The schema itself is checked against its draft's meta-schema first, so a typo such as "type": "strin" is reported as an invalid schema rather than ignored. Annotations like title, description and examples are fine, and so are keywords the draft doesn't know, such as your own x- annotations: they are ignored.

Reading the errors

  • Paths are written as JSONPath, starting from $, the whole document: $.ingredients[1].unit is the unit of the second ingredient.
  • A missing required property is reported on the object that should have it, with the property's name in the message.
  • An extra property that the schema doesn't allow points at that property's name.
  • For enum and const, the message lists the allowed values.
  • With anyOf and oneOf, every branch that fails adds its own errors, followed by one for the keyword itself, so one wrong value can produce several errors.

The error messages come from the Ajv library, in English.

Formats

Values with a format are checked too: email, uri, uri-reference, date, time, date-time, duration, uuid, ipv4, ipv6, hostname, regex, json-pointer and more. A format the validator doesn't know is ignored, as the JSON Schema specification allows.

References

$ref works for definitions inside the same schema, such as #/$defs/address or #/definitions/address. References to other files or URLs aren't fetched: a schema that needs one is reported as invalid, with the reference it couldn't resolve.

How it works

The tool validates with Ajv, a widely used JSON Schema validator, and checks formats with ajv-formats. Everything runs in your browser: the schema and the data are never uploaded.

Features

  • JSON Schema draft 6, 7, 2019-09 and 2020-12, picked from $schema
  • Every error with its path, keyword and message
  • Failing values marked in the data, with click to scroll
  • Format checks for emails, URIs, dates, UUIDs, IP addresses and more
  • Schema checked against its meta-schema
  • Line and column of JSON syntax errors
  • Runs in your browser