Skip to main content
ponderloop

JSON Schema Validator

JSON Schema validation checks a JSON document against a schema and lists every rule it breaks. On the example order below the result is Invalid: 8 errors, with one entry for each broken rule: its path in the document, its path in the schema and a plain message. Paste your own schema and document and the list updates as you type. It covers a stated subset of draft 2020-12 and draft-07, and warns about keywords it cannot check.

Updated By ponderloop editorial · How we checkRuns in your browser: nothing you enter is uploadedHow this tool works

Results update as you type; nothing is uploaded.

Off by default: in draft 2020-12 a format is a label, not a rule, unless you opt in.

Invalid: 8 errors

8 rules are broken.

Result
Invalid
Errors
8
Schema warnings
0
Formats
Annotation only

Errors

  1. Must have at least 1 character; has 0.

    Value at /customer/name

    Schema rule /properties/customer/properties/name/minLength

  2. Property "role" is not allowed: no other properties are permitted here.

    Value at /customer/role

    Schema rule /properties/customer/additionalProperties

  3. Must match the pattern ^[A-Z]{3}-[0-9]{4}$; got "pen-42".

    Value at /items/0/sku

    Schema rule /properties/items/items/$ref/properties/sku/pattern

  4. Must be at least 1; got 0.

    Value at /items/0/quantity

    Schema rule /properties/items/items/$ref/properties/quantity/minimum

  5. Must be a multiple of 0.01; got 19.999.

    Value at /items/0/price

    Schema rule /properties/items/items/$ref/properties/price/multipleOf

  6. Expected integer, got number.

    Value at /items/1/quantity

    Schema rule /properties/items/items/$ref/properties/quantity/type

  7. Must be one of "pending", "paid", "shipped"; got "refunded".

    Value at /status

    Schema rule /properties/status/enum

  8. Items must be unique; items 0 and 1 are equal.

    Value at /tags

    Schema rule /properties/tags/uniqueItems

Supported keywords

Each row is run by this tool: the schema and the value are shown, and the last column is its own first message.
KeywordsWhat they checkSchemaValueResult
type, enum, constThe kind of value, a fixed list of values, one fixed value{"type":"integer"}2.5Invalid: Expected integer, got number.
properties, required, additionalPropertiesNamed members, members that must exist, and what to do with the rest{"properties":{"a":{"type":"string"}},"required":["a"],"additionalProperties":false}{"a":"x","b":1}Invalid: Property "b" is not allowed: no other properties are permitted here.
patternProperties, propertyNamesRules for members chosen by a pattern, and rules for the member names themselves{"patternProperties":{"^x-":{"type":"string"}}}{"x-id":5}Invalid: Expected string, got integer.
minProperties, maxProperties, dependentRequiredHow many members, and members that need other members{"dependentRequired":{"card":["cvc"]}}{"card":"4111"}Invalid: Property "cvc" is required when "card" is present.
items, prefixItemsA schema for every element, or one schema per position (draft-07 tuple items also works){"prefixItems":[{"type":"string"},{"type":"integer"}]}["a","b"]Invalid: Expected integer, got string.
minItems, maxItems, uniqueItemsArray length, and no two equal elements{"uniqueItems":true}[{"a":1},{"a":1.0}]Invalid: Items must be unique; items 0 and 1 are equal.
contains, minContains, maxContainsHow many elements must match a schema{"contains":{"type":"string"},"minContains":2}["a",1]Invalid: Must contain at least 2 items matching the "contains" schema; 1 match.
minLength, maxLength, patternString length in Unicode characters, and a regular expression (not anchored){"minLength":3}"😀😀"Invalid: Must have at least 3 characters; has 2.
minimum, maximum, exclusiveMinimum, exclusiveMaximumNumber bounds, compared as exact decimals{"exclusiveMinimum":0}0Invalid: Must be greater than 0; got 0.
multipleOfThe number divided by the step is a whole number, in exact decimal arithmetic{"multipleOf":0.01}0.07Valid
allOf, anyOf, oneOf, notAll, at least one, exactly one, or none of the subschemas{"oneOf":[{"type":"number"},{"type":"integer"}]}3Invalid: Must match exactly one of the 2 schemas in "oneOf"; it matches 2 (numbers 0, 1, counting from 0).
if, then, elseA condition that picks which schema applies{"if":{"properties":{"kind":{"const":"a"}}},"then":{"required":["x"]}}{"kind":"a"}Invalid: Missing required property "x".
$ref, $defs, definitionsReuse a subschema through a local pointer such as #/$defs/name; cycles are detected{"$ref":"#"}1Invalid: Circular reference: "#" leads back to itself without looking at a smaller part of the value, so it can never finish.
formatdate, date-time, email, uri, uuid, ipv4, ipv6; checked only when the switch is on{"format":"ipv4"}"10.0.0.256"Invalid: Must be a valid ipv4; got "10.0.0.256".

Tricky cases

Computed by the validator. They are where hand-written checks usually go wrong.
CaseSchema against valueResultWhy
multipleOf 0.01 and 0.07{"multipleOf":0.01} against 0.07ValidFloats say 0.07 / 0.01 is 7.000000000000001; exact decimals give 7.
uniqueItems and 1 versus 1.0{"uniqueItems":true} against [1,1.0]Invalid: Items must be unique; items 0 and 1 are equal.The two numbers are equal, so the array is not unique.
uniqueItems with {"a":1} and {"a":1.0}{"uniqueItems":true} against [{"a":1},{"a":1.0}]Invalid: Items must be unique; items 0 and 1 are equal.Objects are equal when their members are, in any key order.
integer and 1.0{"type":"integer"} against 1.0ValidFrom draft 6 on, a number with a zero fraction is an integer.
oneOf with overlapping branches{"oneOf":[{"type":"number"},{"type":"integer"}]} against 3Invalid: Must match exactly one of the 2 schemas in "oneOf"; it matches 2 (numbers 0, 1, counting from 0).Both branches match 3, so oneOf fails; 2.5 would match only the first.
const with different spellings{"const":{"a":[1,2]}} against {"a":[1.0,2]}ValidCompared by value, not by the text that was written.
A $ref that points at itself{"$ref":"#"} against 1Invalid: Circular reference: "#" leads back to itself without looking at a smaller part of the value, so it can never finish.Reported as an error instead of looping forever.

Not supported, or different from a full validator

FeatureWhat this tool does
$dynamicRefWarned about and ignored: dynamic references are not supported.
$dynamicAnchorWarned about and ignored: dynamic anchors are not supported.
$recursiveRefWarned about and ignored: recursive references are not supported.
$recursiveAnchorWarned about and ignored: recursive anchors are not supported.
$anchorWarned about and ignored: anchors are not supported; use a "#/..." JSON Pointer instead.
unevaluatedPropertiesWarned about and ignored: it needs annotation tracking, which this tool does not do.
unevaluatedItemsWarned about and ignored: it needs annotation tracking, which this tool does not do.
$vocabularyWarned about and ignored: vocabularies are not supported.
Remote $ref (https://..., other files)Warned about and not loaded: the page never makes a network request for your schema.
$id and base URIsNot used to resolve references; only "#" and "#/..." pointers into the schema you pasted work.
contentEncoding, contentMediaType, contentSchema, title, description, default, examplesAnnotations: ignored without a warning, as the spec allows.
format other than date, date-time, email, uri, uuid, ipv4, ipv6Not checked; with the switch on you get a warning naming the format.
Unknown keywordsIgnored, as the spec requires.

How to validate JSON against a schema

  1. Paste the schema. Put the JSON Schema in the first box, or keep the example order schema. A syntax error in either box is shown with its line and column.
  2. Paste the document. Put the JSON you want to check in the second box. The example order breaks 8 rules. Use “Valid example” to see it pass.
  3. Decide about formats. Leave “Check formats” off to follow the spec, where format is only a label, or turn it on to make date, email, uri, uuid and IP formats real rules. On the example it adds 2 errors.
  4. Read the errors. Each error shows the value’s path (a JSON Pointer such as /items/0/sku), the schema rule that failed and a message. Fix them top to bottom; warnings tell you which schema keywords were not checked.

Frequently asked questions

Which JSON Schema drafts does this validator follow?
It follows draft 2020-12 and also understands the draft-07 spellings that differ: the tuple form of items with additionalItems, dependencies and definitions. If the schema’s $schema names draft-07 (or 06 or 04), a $ref ignores its sibling keywords, as that draft says; otherwise they are all applied. It is a subset, not a complete implementation. On the example, 8 rules fail across 8 different keywords.
Why is format validation optional?
Since draft 2019-09 a format is an annotation by default: a validator may leave it unchecked, and many do. The spec lets you opt in to assertion, which is what the switch does. Switch it off and the example gives Invalid: 8 errors; switch it on and it gives Invalid: 10 errors, because the order id is not a UUID and the email has no domain. Only date, date-time, email, uri, uuid, ipv4, ipv6 are checked, in the practical form most validators use, so an unusual but legal email or URI can differ from a stricter library.
What are the limits of $ref here?
Only references into the schema you pasted work: “#” for the whole schema and “#/$defs/name” or “#/definitions/name” (any JSON Pointer works). A remote reference such as https://example.com/a.json is not fetched, because the page never makes network requests for your data; it is reported as a warning (2 warnings for a schema with a remote $ref and unevaluatedProperties) and not checked. $anchor, $dynamicRef and $id-based lookups are not supported. A reference that points back at itself with no progress, such as {"$ref":"#"}, is reported as a circular reference instead of hanging. Recursive schemas that look at a smaller part of the value each time, like a tree, are fine.
What is the difference between anyOf, oneOf and allOf?
allOf needs every subschema to pass, anyOf at least one and oneOf exactly one. The oneOf trap is overlap: with branches number and integer, the value 3 matches both, so it fails. Invalid: Must match exactly one of the 2 schemas in "oneOf"; it matches 2 (numbers 0, 1, counting from 0). For anyOf and oneOf the tool reports one error for the keyword with the number of branches that matched, not a list of every branch’s failures, because those failures are not all real problems.
Why does a multipleOf check not give float errors?
Numbers are compared as exact decimals, not floats. In floating point 0.07 / 0.01 is 7.000000000000001, so a float check of multipleOf 0.01 wrongly rejects 0.07. Here the result is: Valid The same exactness makes 1.0 equal to 1 for enum, const and uniqueItems, and lets a number with a zero fraction count as an integer. Numbers beyond about 400 digits fall back to floating point.
What does additionalProperties: false actually forbid?
It forbids members that are not named in the same schema’s properties or matched by its patternProperties. It does not look inside allOf, anyOf or $ref, so a schema that combines other schemas with allOf and sets additionalProperties to false rejects members that the combined schemas allow. unevaluatedProperties solves that in 2019-09 and later, but it needs annotation tracking, which this tool does not do and warns about. In the example, the customer object gets 1 error for its unexpected role member.
How do I read the two paths in an error?
Both are JSON Pointers (RFC 6901): a slash-separated route where ~1 stands for a slash and ~0 for a tilde. The first is where the bad value sits in your document, for example /items/0/sku. The second is the keyword that failed in the schema, following any $ref, for example /properties/items/items/$ref/properties/sku/pattern. An empty instance path means the whole document.
Is my schema or JSON uploaded anywhere?
No. Both are parsed and checked in your browser, nothing you paste is sent to a server or stored, and the analytics event for this tool never includes the schema or the document.

How it works

The schema and the document are read with a strict RFC 8259 reader that keeps numbers as written and keys in order. The validator walks the schema keyword by keyword, as the JSON Schema 2020-12 validation vocabulary describes, and records an error for each failed keyword with the instance path and the schema path (keywords reached through $ref include the $ref step). Numbers are turned into exact fractions, so comparisons and multipleOf have no rounding error. Equality for enum, const and uniqueItems compares numbers by value and objects without regard to key order. Subschemas of anyOf, oneOf, not, contains and if are evaluated quietly, and only their verdict is used. The example order gives Invalid: 8 errors.

Sources

More: Formatters and data convertersAll developer toolsAll toolsHome & DIY calculators