Articles

How to validate JSON and find the error

A direct way to check quotes, commas, brackets, and value types when JSON fails validation.

JSON can look tidy and still fail to parse. Reading it from the top again is slow because the eye fills in familiar structure and skips a single wrong character. A parser message gives a better starting point, especially when you inspect the text just before the reported position.

Run validation before editing

Paste the complete document into JSON Formatter and format it. Valid JSON receives readable indentation. Invalid input produces the position where parsing could no longer continue. The character that caused the problem often appears slightly earlier.

Check the five common failures

  1. Keys and string values need double quotes.
  2. Items need commas between them, with no comma after the final item.
  3. Every opening curly or square bracket needs a matching closing bracket.
  4. JSON does not allow comments, functions, or JavaScript expressions.
  5. The values true, false, and null use lowercase letters and no quotes.

Why the reported position looks wrong

A parser reports where the structure finally became impossible to read. A missing quote can turn a colon and comma into part of a string, so the error appears after the real cause. Start at the reported position and move backward to the previous key or separator.

Formatting and minifying are different jobs

Formatting adds whitespace to expose nesting. Minifying removes unnecessary whitespace from a document that is already valid. It does not repair syntax. Find the error first and create the compact version only after validation passes.

Check value meaning after syntax

Valid JSON can still violate an API contract. The number 42 and the string "42" have different types. An empty array, empty object, and null are also distinct. Compare the result with the schema or documentation used by the receiving service.

Try it now

JSON Formatter

Format, minify and validate JSON directly in your browser.

Open the tool
Continue with
Password generatorQR code generatorAll tools