Skip to main content
CuteJSON
↑↓ Navigate Enter Select Esc Close

How to validate JSON against a JSON Schema

Published 2 min read By Akash Kinkar Pandey

A schema is only useful if you can actually check a document against it and get a clear answer about what failed and where. This validator covers the subset of JSON Schema the generator on this site writes, so a schema produced there is guaranteed to be one this page can apply.

Using the JSON Schema validator

Paste a schema on the left and the document to check on the right, then press Validate. Loading the sample fills both panes at once, so you can edit just the document and immediately see what the schema rejects.

Given the schema

{
  "type": "object",
  "properties": {
    "age": {"type": "integer", "minimum": 0},
    "name": {"type": "string", "minLength": 2}
  },
  "required": ["age", "name"]
}

and the document {"age": -5, "name": "A"}, validation reports two problems in one pass: minimum failed at /age because -5 is below 0, and minLength failed at /name because "A" is one character. Every problem is reported, not just the first one, and each carries the exact keyword that rejected it and a JSON Pointer to the value, so a problem is a path you can walk to rather than a sentence you have to decode.

What is supported

Type, enum and const; the properties, patternProperties, additionalProperties and required keywords; length, pattern and format on strings; bounds and multiples on numbers; items and uniqueItems on arrays; the allOf, anyOf, oneOf and not combinators; if-then-else; and local references through $defs or definitions. A keyword this validator does not implement is treated as an annotation and ignored, which is exactly what the JSON Schema specification permits a validator to do with an unrecognised keyword.

What stops the whole check

A $ref that names nothing inside the schema, or one that points outside it entirely, stops validation altogether and says so. Reporting a pass or fail result for a schema that could not be fully resolved would be a lie dressed up as an answer, so the tool refuses to give one.

Swap sides

Since the schema and document panes are visually similar, Swap sides moves the current schema into the document pane and vice versa, useful if you pasted them in the wrong boxes or want to quickly check a schema for basic sanity against itself.

Back to all posts