JSON Schema validator

Check a JSON document against a JSON Schema (drafts 2020-12, 2019-09 and 07).

loading JSON Schema validator
About this tool

What is a JSON Schema validator?

A JSON Schema describes what a JSON document must look like: which properties are required, which types they have, which values are allowed, how long a list may be. A validator takes the schema and a document and tells you whether the document follows it. It is the check behind API contracts, configuration files, OpenAPI request bodies and form payloads, and it is the fastest way to find out why a service rejected your JSON.

This tool checks a document against a schema in your browser and lists every problem, not only the first. Each one shows the JSON path of the value (for example $.items[1].qty), a short explanation of the rule that failed, and the line and column in your document; click a problem to jump to that line. It understands drafts 2020-12, 2019-09 and 07, chosen from the $schema keyword or by you. Nothing is uploaded, and a $ref that points to another file or URL is never fetched: copy those definitions into $defs and refer to them with #/$defs/name.

The checks run without generating code, so the page works even where the browser forbids it, and a very large or endlessly recursive schema stops with a clear message instead of freezing the tab. Formats such as email, date, date-time, uuid, ipv4, ipv6 and hostname are checked; a format the tool does not know is ignored, as the specification allows.

How to validate JSON against a schema

  1. Paste the schema on the left and the JSON to check on the right. Press load example to see a schema with a document that has several problems.
  2. Leave the draft on auto to follow the schema's $schema, or pick one. Without $schema the newest draft (2020-12) is used.
  3. Read the verdict under the panels. If it is valid you get a green confirmation; otherwise the list shows each problem with its path and position.
  4. Click a problem to select that line in your JSON, fix it and watch the list shrink. The result updates as you type.
  5. When the JSON is valid, continue with the JSON formatter or compare two versions with JSON diff.

Examples

A missing property and a wrong type

Schema: {"type":"object","required":["id","name"],"properties":{"id":{"type":"integer"}}}. Document: {"id":"7"}. Two problems: $.id expected integer, found string, and the required property name is missing at $.

A value outside the allowed set

Schema: {"properties":{"status":{"enum":["paid","pending"]}}}. Document: {"status":"shipped"}. The problem at $.status lists the allowed values, which is usually all you need to fix it.

A reusable definition

Schema: {"$defs":{"qty":{"type":"integer","minimum":1}},"properties":{"a":{"$ref":"#/$defs/qty"},"b":{"$ref":"#/$defs/qty"}}}. Document: {"a":0,"b":2}. Only $.a fails, with "must be at least 1", even though the rule is written once.

Common mistakes

  • Expecting a remote $ref to load. The tool never makes network requests. Inline the definition under $defs.
  • Forgetting required. A property listed under properties is optional unless it is also in required.
  • Using additionalProperties: false with allOf. Properties declared inside allOf branches do not count for the outer additionalProperties; use unevaluatedProperties (2019-09 and later) instead.
  • Mixing drafts. prefixItems exists only in 2020-12; older drafts use items as a list. Pick the draft that matches your validator in production.
  • Numbers written as strings. "7" is a string, not an integer, even if it looks like one.

Frequently asked questions

Which JSON Schema drafts are supported?

2020-12, 2019-09 and 07, including $defs, $anchor, if/then/else, dependentRequired, unevaluatedProperties and unevaluatedItems.

Is my JSON or schema sent anywhere?

No. Both are validated in your browser and neither is stored; only the draft you chose is remembered.

Why does a $ref to a URL fail?

Fetching a remote file would be a network request, which this tool never makes. Copy the definition into $defs and point to it with #/$defs/name.

Does it check that my schema is correct?

It reports a schema it cannot use, such as an unknown type, a broken regular expression or a $ref that points nowhere, with the place where it found the problem.

Report a problem