Need safe multi-accounting? Compare the top-rated solutions at AntiDetect Hub. Explore Now

JSON Schema Validator

0 of 0 ratings

Paste the JSON data on the left and the JSON Schema on the right, or open files. The data is checked as you type, or press Validate. Nothing is uploaded: both stay in your browser.

You can also drop a file on the box.
You can also drop a file on the box.

JSON Schema Validator Online

Check that JSON data follows a JSON Schema: paste the data on the left and the schema on the right, and the tool says whether the data is valid and, if not, lists every place that breaks a rule, with its path, its line and column and a plain explanation. Everything happens in your browser: neither the data nor the schema is uploaded.

JSON validator or JSON Schema validator?

A JSON validator checks the syntax only: quotes, commas, brackets. A JSON Schema validator goes further and checks the content: that the required fields are there, that each value has the right type, that numbers are in range, that strings match a pattern, that only allowed values are used. This page does both: a syntax mistake in either box is shown first with its line and column, then the data is checked against the schema. For syntax only and formatting, use the JSON Beautifier & Validator.

An example

The data has a price written in quotes:

{
  "name": "DIEG",
  "price": "19.99"
}

The schema wants a number:

{
  "type": "object",
  "properties": {
    "name": { "type": "string" },
    "price": { "type": "number" }
  },
  "required": ["name", "price"]
}

The result is "Invalid" with one error at $.price: "Expected a number, but the value is a string ("19.99"). Remove the quotes around 19.99 to make it a number." Press "Example" to try it.

How to read the result

  • Path: where the problem is, written as a JSONPath: $ is the whole document, $.items[0].price is the price of the first item.
  • Problem: what is wrong in plain words, with a hint for the usual cases: a number or true/false in quotes, a number where text is expected, a decimal where a whole number is required.
  • Place: the line and column in your data; a click selects the value in the box. A missing required field points at the object that should have it.
  • Rule: the part of the schema that was broken, for example /properties/price/type; a click selects it in the schema box.
  • The result can be copied as text, for a ticket or a chat.

Mistakes in the schema itself

Validators silently ignore keywords they do not know, so a schema with "requried" instead of "required" lets everything pass. This tool lists such typos with a suggestion, and also values of the wrong kind: a type name that does not exist, required that is not a list, a negative minLength, a pattern that is not a valid regular expression.

Drafts and keywords

  • Draft-04, Draft-07, 2019-09 and 2020-12. With "Draft: automatic" the draft is taken from the $schema line of the schema, and without it 2020-12 is used; you can also choose the draft yourself. The page says which one was used.
  • All the usual keywords: type, required, properties, additionalProperties, patternProperties, items, prefixItems, enum, const, minimum and maximum, minLength and maxLength, pattern, minItems and maxItems, uniqueItems, allOf, anyOf, oneOf, not, if/then/else, dependentRequired, $ref and $defs.
  • The format keyword is checked: email, date, date-time, time, uri, uuid, ipv4, ipv6, hostname and others.

What it is used for

  • Testing an API: does the response match the contract in the documentation, with the right fields, types, nested objects and arrays?
  • Configuration files: is a settings file complete and correct before deployment?
  • Data exchange: are imported or exported records what the other side expects?
  • Writing a schema: try it on good and bad examples and see what it lets through.

Limitations

  • A $ref must point inside the schema, such as #/$defs/address. The tool works in your browser and does not download other schemas, so references to other files or URLs (common in schemas from SchemaStore) cannot be followed; the page says so.
  • $dynamicRef and custom vocabularies are supported only in part. Measured on the official JSON Schema test suite, the checker agrees with about 96 to 97 percent of the assertions for Draft-04, Draft-07 and 2019-09 and 93 percent for 2020-12; the rest are those references and the rule that format is only an annotation (here it is checked).
  • Both texts must be strict JSON: comments and trailing commas are syntax errors. YAML schemas are not read.
  • Everything is held in the memory of the browser, so files of many megabytes are slow, most of all on a phone.

Similar tools

JSON Beautifier & Validator

Beautify, minify and validate JSON online. Open a file, see the exact line and column of a syntax error, download the result. Works in your browser, nothing is uploaded.

8
HTML to Markdown

Convert HTML to Markdown online for Hugo, Astro, Grav and others. Paste a page or formatted text, optional front matter. Works in your browser, nothing is uploaded.

6
Base64 Encoder / Decoder

Encode text to Base64 or decode Base64 back to text online, instantly in your browser. UTF-8 and URL-safe Base64 supported.

12

Popular tools