Help

JSON Schema Validator Online: Check JSON Against a Schema

Paste a JSON Schema and the JSON you want to check, and see at once whether the data matches. If it does not, every error is listed with the path to the value that failed and a plain reason, such as $.users[0].email. It handles draft-07, 2019-09 and 2020-12, and both boxes stay on your device.

How to validate JSON against a schema

  1. Paste your schema into the JSON Schema box (it says Paste your JSON Schema here...).
  2. Paste the JSON to check into the JSON Data box (Paste the JSON data to check here...).
  3. Read the Result. It updates on paste, or about 300 milliseconds after you stop typing, so there is nothing to press.
  4. A green Valid with The JSON data matches the schema. means the data passes. A red Invalid: N errors lists each failure.
  5. Fix the data (or the schema), and the result changes as you edit.

Until both boxes are filled the Result says Paste a schema and the JSON data to check them. If either box holds text that is not JSON, a red Invalid JSON box gives the reason and Line X, column Y, and the Result tells you which box to fix. To tidy a messy document first, the JSON Formatter shows the same line and column for broken JSON.

How to read the errors: paths and reasons

Every error has two parts: a path and a reason. The path starts at $, the root of your data, and follows property names with dots and array positions in square brackets, counting from 0. Here is a small schema and some data that breaks three rules:

JSON Schema {"type":"object","required":["id","email"],
"properties":{"id":{"type":"integer","minimum":1},
"email":{"type":"string","format":"email"},
"tags":{"type":"array","items":{"type":"string"},"uniqueItems":true}}}
JSON Data {"id":"7","email":"ana@","tags":["a","a"]}

The Result reads Invalid: 3 errors:

PathReason
$.idMust be an integer, but this is a string.
$.emailMust match the format “email”.
$.tagsItems [0] and [1] are identical, but every item must be different.

All errors are listed, not just the first one, so you can fix a whole document in one pass. After 100 errors the list stops with a line such as and 250 more errors not shown; the count in the heading is still exact.

What each error reason means

Schema keywordReason you will see
requiredMissing required property “name”. It is shown at the path of the object that should hold it, for example $.users[0].
typeMust be a number, but this is a string.
enum, constThe allowed values are listed, or the one exact value that is required.
minimum, maximum, multipleOfMust be at least, at most, greater than, less than, or a multiple of the number given.
minLength, maxLengthMust be at least 3 characters long.
minItems, maxItems, uniqueItemsMust have at least 1 item, or two items are identical.
pattern, formatMust match the pattern, or the format “email”.
oneOf, anyOfDoes not match any of the schemas in oneOf, or matches more than one when exactly one is allowed.

Rarer keywords such as not, contains, propertyNames, dependentRequired and if/then/else have their own plain reasons as well.

Strict mode: reject properties the schema does not list

By default JSON Schema allows extra properties, so data with an unlisted nick field passes a schema that never mentions it. Switch on Strict mode (Fail when the data has properties the schema does not list.) to catch typos and leftovers. With the schema above and the data {"id":1,"email":"ana@example.com","nick":"x"}:

Strict modeResult
OffValid
OnInvalid: 1 error. $: Unexpected property “nick”. The schema does not list it.

Behind the switch, the tool adds unevaluatedProperties: false to the root schema and to each property or item schema that describes an object, which also works across $ref. Your text in the box is never changed.

Which JSON Schema versions are supported

The tool reads the "$schema" line of your schema and checks the data with the matching rules.

Your schema saysChecked as
http://json-schema.org/draft-07/schema#draft-07
https://json-schema.org/draft/2019-09/schema2019-09
https://json-schema.org/draft/2020-12/schema2020-12
no "$schema" at all2020-12, or 2019-09 for older syntax such as an items array
draft-04, draft-06 or any other addressNot supported; the Result says which address the schema declares

That matters for keywords that changed between drafts. prefixItems is 2020-12 and definitions became $defs in 2019-09, while draft-07 still uses definitions and tuple items arrays. Both spellings of the reference path work: #/$defs/name and #/definitions/name.

$ref, formats and schema errors

Limits and what this tool does not do

Frequently asked questions

How do I validate JSON against a JSON Schema online?

Paste the schema into the JSON Schema box and the JSON you want to check into the JSON Data box. The result appears at once on paste, or about 300 milliseconds after you stop typing. A green Valid means the data matches. A red Invalid lists every error with its path and the reason. There is no button to press.

Which JSON Schema versions does it support, draft-07, 2019-09 or 2020-12?

All three. The version comes from the schema's "$schema" line. A schema without "$schema" is checked as 2020-12, or as 2019-09 when it uses older syntax such as an items array. Schemas that declare draft-04, draft-06 or any other $schema address are reported as unsupported.

What does a path like $.users[0].email mean?

It is the location of the value that failed. $ is the root of your JSON data, .users is the property called users, [0] is the first item of that array (counting starts at 0) and .email is the property inside it. A path such as $.users[2].address.zip leads the same way, one step at a time.

Why is a missing required property reported on the parent object?

Because the property is not there to point at. The error is shown at the path of the object that should contain it, for example $.users[0] with the reason Missing required property “email”. Add the property to that object and the error goes away.

How do I make the schema reject extra properties (additionalProperties false)?

Turn on Strict mode. It adds unevaluatedProperties: false to the root and to every property and item schema that describes an object, so any property the schema does not list fails as Unexpected property. Schemas that already set additionalProperties or unevaluatedProperties keep their own choice.

Does it check formats such as email, date-time, uri and uuid?

Yes. The "format" keyword is checked, so an address like ana@ fails a string with "format": "email" and shows Must match the format “email”. The common formats are covered, including email, date, date-time, time, uri, uuid, ipv4, ipv6 and hostname.

Can it follow a $ref to another file or a URL?

Only inside the same schema, such as #/$defs/name or #/definitions/name. Nothing is downloaded, so a reference like https://example.com/address.json is reported as a reference the schema does not define. Copy the referenced schema into your $defs and point the $ref there.

What does "The schema itself is not valid" mean?

The schema breaks the JSON Schema rules, for example "type": "strng" or a "minimum" given as text. The result lists the problems with paths that point into the schema, and the data is not checked until the schema is fixed.

Why does it say my draft-04 or draft-06 schema is not supported?

The tool checks draft-07, 2019-09 and 2020-12. A draft-06 schema usually works unchanged once its "$schema" line is replaced with the draft-07 address. Draft-04 differs more ("id" instead of "$id", and a true or false "exclusiveMinimum"), so review those keywords before switching.

Can it validate YAML or an OpenAPI document?

No. Both boxes take JSON only. Convert YAML to JSON first. A whole OpenAPI file is not a JSON Schema either, so paste the schema object from its components section as the JSON Schema.

Is my schema or JSON data uploaded anywhere?

No. Both are checked on your device in the browser, and nothing is uploaded or saved.

How big can the schema and the data be, and how many errors are shown?

Each box accepts up to 5,000,000 characters. Every error is found and counted, and the first 100 are listed, followed by a line such as and 250 more errors not shown.

Recommended

Helps keep the tools free. ✨

Images are for illustration only. As an Amazon Associate I earn from qualifying purchases.