JSON Schema Validator

Check a JSON document against a JSON Schema and list every error.

About JSON Schema Validator

Validate a JSON document against a JSON Schema in the browser and list every error with its path, the failing keyword and a message.

How to use

  1. Paste or load the schema on the left and the document on the right (.json files, up to 5 MB each). Each side reports its own JSON syntax error until it parses.
  2. The result appears as you type: "Valid", or a table of errors with the draft that was used.
  3. Each row gives the path to the failing value as a JSON Pointer (/items/0/name, or (root) for the document itself), the schema keyword that failed and the validator's message.
  4. Copy the errors, or Download them as a tab-separated file.

What it does

  • Validation is done by @cfworker/json-schema, which supports drafts 4, 7, 2019-09 and 2020-12. The draft is taken from the schema's $schema. A draft-06 schema is checked as draft 7, and a schema with no $schema, or one that is not recognised, as 2020-12.
  • Every error is collected, not only the first. A failure deep in the document also appears on each enclosing properties or items keyword, and anyOf and oneOf list the errors of each branch.
  • format is checked for date, time, date-time, duration, uri, uri-reference, uri-template, url, email, hostname, ipv4, ipv6, regex, uuid, json-pointer, json-pointer-uri-fragment and relative-json-pointer. Other formats are ignored.
  • A $ref to a definition inside the same schema, such as #/$defs/address, is followed.
  • It does not fetch anything: a $ref to another file or URL is reported as unresolved.
  • It does not check the schema against its meta-schema, so a misspelt keyword is ignored without a warning.
  • Numbers are read as JavaScript numbers, so an integer above 2^53 is rounded before it is checked.
  • The table shows the first 500 errors; Copy and Download include all of them.

Example

Schema
{ "type": "object", "properties": { "id": { "type": "integer" } }, "required": ["id"] }

Document
{ "id": "42" }

Errors
(root)  properties  Property "id" does not match schema.
/id     type        Instance type "string" is invalid. Expected "integer".

Privacy

Validation runs in the page. Dropped files are read locally, no request is made, not even for a remote $ref, and nothing is stored.

Frequently asked questions

Which JSON Schema draft should I use?
Use 2020-12 for new schemas unless a tool you depend on needs an older draft; OpenAPI 3.1, for example, is built on 2020-12. Declare the draft with $schema so that every validator reads the keywords the same way.
What does $schema do in a JSON Schema?
It names the draft the schema is written for, for example https://json-schema.org/draft/2020-12/schema. Validators use it to decide how to read keywords whose meaning changed between drafts, such as items and exclusiveMinimum.
Why does my JSON pass validation when it has extra properties?
JSON Schema allows properties that the schema does not mention. Add "additionalProperties": false to the object schema to reject them.
Is format validated in JSON Schema?
It depends on the validator: since draft 2019-09 the specification treats format as an annotation unless assertion is switched on. This tool does check the formats it knows, such as date-time, email and uuid, and ignores the rest.