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
Invalid: 8 errors
8 rules are broken.
- Result
- Invalid
- Errors
- 8
- Schema warnings
- 0
- Formats
- Annotation only
Schema warnings
Errors
Must have at least 1 character; has 0.
Value at
/customer/nameSchema rule
/properties/customer/properties/name/minLengthProperty "role" is not allowed: no other properties are permitted here.
Value at
/customer/roleSchema rule
/properties/customer/additionalPropertiesMust match the pattern ^[A-Z]{3}-[0-9]{4}$; got "pen-42".
Value at
/items/0/skuSchema rule
/properties/items/items/$ref/properties/sku/patternMust be at least 1; got 0.
Value at
/items/0/quantitySchema rule
/properties/items/items/$ref/properties/quantity/minimumMust be a multiple of 0.01; got 19.999.
Value at
/items/0/priceSchema rule
/properties/items/items/$ref/properties/price/multipleOfExpected integer, got number.
Value at
/items/1/quantitySchema rule
/properties/items/items/$ref/properties/quantity/typeMust be one of "pending", "paid", "shipped"; got "refunded".
Value at
/statusSchema rule
/properties/status/enumItems must be unique; items 0 and 1 are equal.
Value at
/tagsSchema rule
/properties/tags/uniqueItems
Supported keywords
| Keywords | What they check | Schema | Value | Result |
|---|---|---|---|---|
| type, enum, const | The kind of value, a fixed list of values, one fixed value | {"type":"integer"} | 2.5 | Invalid: Expected integer, got number. |
| properties, required, additionalProperties | Named 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, propertyNames | Rules 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, dependentRequired | How many members, and members that need other members | {"dependentRequired":{"card":["cvc"]}} | {"card":"4111"} | Invalid: Property "cvc" is required when "card" is present. |
| items, prefixItems | A 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, uniqueItems | Array 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, maxContains | How 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, pattern | String length in Unicode characters, and a regular expression (not anchored) | {"minLength":3} | "😀😀" | Invalid: Must have at least 3 characters; has 2. |
| minimum, maximum, exclusiveMinimum, exclusiveMaximum | Number bounds, compared as exact decimals | {"exclusiveMinimum":0} | 0 | Invalid: Must be greater than 0; got 0. |
| multipleOf | The number divided by the step is a whole number, in exact decimal arithmetic | {"multipleOf":0.01} | 0.07 | Valid |
| allOf, anyOf, oneOf, not | All, at least one, exactly one, or none of the subschemas | {"oneOf":[{"type":"number"},{"type":"integer"}]} | 3 | Invalid: Must match exactly one of the 2 schemas in "oneOf"; it matches 2 (numbers 0, 1, counting from 0). |
| if, then, else | A condition that picks which schema applies | {"if":{"properties":{"kind":{"const":"a"}}},"then":{"required":["x"]}} | {"kind":"a"} | Invalid: Missing required property "x". |
| $ref, $defs, definitions | Reuse a subschema through a local pointer such as #/$defs/name; cycles are detected | {"$ref":"#"} | 1 | Invalid: Circular reference: "#" leads back to itself without looking at a smaller part of the value, so it can never finish. |
| format | date, 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
| Case | Schema against value | Result | Why |
|---|---|---|---|
| multipleOf 0.01 and 0.07 | {"multipleOf":0.01} against 0.07 | Valid | Floats 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.0 | Valid | From draft 6 on, a number with a zero fraction is an integer. |
| oneOf with overlapping branches | {"oneOf":[{"type":"number"},{"type":"integer"}]} against 3 | Invalid: 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]} | Valid | Compared by value, not by the text that was written. |
| A $ref that points at itself | {"$ref":"#"} against 1 | Invalid: 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
| Feature | What this tool does |
|---|---|
| $dynamicRef | Warned about and ignored: dynamic references are not supported. |
| $dynamicAnchor | Warned about and ignored: dynamic anchors are not supported. |
| $recursiveRef | Warned about and ignored: recursive references are not supported. |
| $recursiveAnchor | Warned about and ignored: recursive anchors are not supported. |
| $anchor | Warned about and ignored: anchors are not supported; use a "#/..." JSON Pointer instead. |
| unevaluatedProperties | Warned about and ignored: it needs annotation tracking, which this tool does not do. |
| unevaluatedItems | Warned about and ignored: it needs annotation tracking, which this tool does not do. |
| $vocabulary | Warned 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 URIs | Not used to resolve references; only "#" and "#/..." pointers into the schema you pasted work. |
| contentEncoding, contentMediaType, contentSchema, title, description, default, examples | Annotations: ignored without a warning, as the spec allows. |
| format other than date, date-time, email, uri, uuid, ipv4, ipv6 | Not checked; with the switch on you get a warning naming the format. |
| Unknown keywords | Ignored, as the spec requires. |
How to validate JSON against a schema
- 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.
- 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.
- 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.
- 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
- JSON Schema 2020-12: Core (json-schema.org)
- JSON Schema 2020-12: Validation, including formats in section 7 (json-schema.org)
- JSON Schema draft-07: Validation (json-schema.org)
- RFC 6901: JavaScript Object Notation (JSON) Pointer (IETF)
- RFC 3339: Date and Time on the Internet: Timestamps (IETF)
- RFC 8259: The JSON Data Interchange Format (IETF)
More free tools
- JSONPath TesterTest JSONPath expressions (RFC 9535) on your JSON: matched values, normalized paths, match count and errors with position. Runs in your browser.
- JSON to TypeScript Interface GeneratorPaste JSON and get TypeScript interfaces or types: named nested interfaces, ? on optional keys, unions for mixed arrays. Runs in your browser.
- Online Markdown Editor With Live PreviewWrite Markdown with a live, safe preview. Toolbar, shortcuts, word count, copy HTML, download .md and an autosaved draft. Runs in your browser.
- SQL FormatterFormat and beautify SQL: one clause per line, one column per line, indented subqueries and CASE, keywords in your case. Or minify. Runs in your browser.
- JSON Formatter & ValidatorValidate JSON with the exact line and column of any error, then pretty-print, minify or sort keys. Big numbers keep every digit. Runs in your browser.
- CSV to JSON ConverterConvert CSV to JSON in your browser: quoted fields, line breaks, any delimiter, and the exact line and column of an error. Converts JSON to CSV too.
More: Formatters and data convertersAll developer toolsAll toolsHome & DIY calculators