Skip to content
SDETRole
SDETRole

JSON & Data

JSON Validator

Check JSON syntax and pinpoint the exact error location.

Runs entirely in your browser No sign-up

Input JSON

0 chars

About this tool

A syntax error in a fixture file or request body is one of the most common causes of a confusing test failure. This validator checks JSON against the strict standard and reports the first error with its line and column, along with a summary of the document’s structure (objects, arrays, keys and depth) when it is valid. To validate the shape of the data rather than its syntax, use the JSON Schema Validator.

How to use it

  1. Paste the JSON you want to check.
  2. Read the result banner: green means valid, red shows the error message and location.
  3. Fix the reported location and the result updates as you type.

What counts as valid JSON

The validator applies the strict grammar of RFC 8259, the same rules JSON.parse uses. A document is a single value: an object, an array, a string, a number, true, false or null. A bare "hello" or 42 is therefore valid JSON, even though most APIs return an object.

Duplicate keys are a common trap. The standard says object names SHOULD be unique but does not forbid repeats, and JSON.parse silently keeps the last value. A syntax check will not flag {"id": 1, "id": 2}, so look out for duplicates in code review or with a linter.

Reading the error message

Each browser words parse errors differently. Chrome reports messages such as "Unexpected token" or "Expected property name" with a position, and Firefox gives a line and column. In every case the location is where the parser gave up, which is usually just after the real mistake: a missing comma, an unclosed quote or a stray bracket on the line above.

Validating JSON in automated tests

  • Playwright: await response.json() throws when the body is not valid JSON, so the test fails at that line. Check response.headers()['content-type'] too, because a server can send JSON text labelled as HTML.
  • REST Assured: assert .contentType(ContentType.JSON), then check structure with matchesJsonSchemaInClasspath("order-schema.json") from the json-schema-validator module.
  • Postman: pm.response.json() throws on invalid JSON, and pm.response.to.be.json asserts the content type.
  • For shape and types (required fields, formats, enums), move on to the JSON Schema Validator. Syntax validation only proves the text parses.

JSON Validator FAQ

What is the difference between JSON validation and schema validation?

Syntax validation checks that the text is well-formed JSON. Schema validation checks that well-formed JSON has the expected fields, types and constraints, such as “id is a required integer”.

Why does the error point after the real mistake?

Parsers report where they could no longer continue. A missing comma or quote is usually just before the reported position.

Type to search across SDETRole.

Full-text search by Pagefind · runs in your browser Open search page →