DevToolCase
Sign in Sign in

Validate JSON against a JSON Schema

Check JSON data against a JSON Schema (draft 4, 7, 2019-09 or 2020-12) and see every error with its JSON Pointer path and the rule broken.

Share this result

Encrypted in your browser. The key stays in the link, after “#”: only the people you give it to can read it, not even DevToolCase.

The link works for

Sign in for longer links or links without expiry, and to find them in your account.

Runs entirely in your browser: nothing you type is sent or stored.

What is JSON Schema?

JSON Schema is a JSON document that describes what other JSON documents must look like: which properties an object has, which are required, the type of each value, the allowed range of a number, the pattern of a string… A validator compares data with the schema and lists every rule the data breaks.

Each error here gives the place in the data as a JSON Pointer, the keyword that failed and where it sits in the schema. /items/0/price is the property price of the first item of items; click the pointer to select the value in the data.

The most common keywords

KeywordWhat it checks
typeThe type: object, array, string, number, integer, boolean or null.
propertiesThe schema of each property of an object.
requiredThe properties an object must have.
additionalPropertiesProperties not listed: false forbids them.
itemsThe schema of the items of an array.
enum, constA list of allowed values, or the only one.
minimum, maximumThe range of a number.
minLength, patternThe length of a string, or a regular expression it must match.
formatA known format: date-time, email, uri, uuid, ipv4…
$refReuses a schema defined elsewhere, usually under $defs.
anyOf, oneOf, allOfCombines schemas: at least one, exactly one, or all of them.

Which draft?

JSON Schema has several versions, called drafts. The $schema keyword at the top of a schema says which one it follows, and the validator uses it; without it, the latest, 2020-12, applies. You can also force a draft.

  • Draft 4 (2013): still common in older tools; exclusiveMaximum is a boolean there.
  • Draft 7 (2018): the most widespread, adds if / then / else and const.
  • 2019-09: $defs, dependentRequired, unevaluatedProperties.
  • 2020-12: prefixItems for tuples; it is the draft of OpenAPI 3.1.

What is JSON Schema used for?

  • API contracts: the request and response bodies of OpenAPI (Swagger) are described with JSON Schema.
  • Configuration files: editors such as VS Code use a schema to complete and check package.json, tsconfig.json or a CI file.
  • Data exchange: check a message or a file before importing it, and reject it with a clear reason.
  • Forms: some libraries build a form and its checks from a schema.

No schema yet? Generate one from a JSON sample, then refine it. Is your JSON itself invalid? The JSON formatter shows the exact line of the error. Everything runs in your browser: neither the schema nor the data is sent anywhere.

Add this browser’s favorites to your account?

This browser has 0 favorites that your account does not have:

Either way, this browser keeps its favorites: you find them again after signing out.