JSON Validator
Validate JSON, see parse errors, and copy formatted output.
Written by Anil Gautam · Updated
How do you read a JSON parse error?
The validator hands your text to the browser's built-in JSON.parse. When that fails, the status panel shows the browser's own message, so Chrome, Firefox and Safari word the same error differently. Chrome and Edge give a character position counted from 0 plus a line and column counted from 1. In Chrome an empty box gives Unexpected end of JSON input, and a string value broken across two lines gives Bad control character in string literal, because a line break inside a string has to be written as \n.
The reported spot is where the parser gave up, which is often just past the real mistake. Take an object indented by two spaces, with "a": 1 on line 2, "b": 2 on line 3 and no comma between them. Chrome reports Expected ',' or '}' after property value at line 3 column 3, which is where "b" starts, while the missing comma belongs at the end of line 2. Single-quoted keys fail at the first quote, so {'a': 1} stops at line 1 column 2. Data copied from Python fails at True or None, which JSON spells true and null. A number written with a thousands separator, as in "total": 1,234, fails because the comma ends the value and 234 is not a quoted key.
What does a valid result tell you?
Valid means the text follows JSON syntax. Any single JSON value counts, so 42, "hello" or null on its own passes. The counter adds up keys and values: the sample in the input box has three keys and three values, so it reports 6 values / keys checked. Array items are counted twice, once as positions and once as values, so [1, 2, 3] also reports 6, and an empty {} reports 0.
Some problems still pass. JSON.parse accepts duplicate keys and keeps the last one, so {"a": 1, "a": 2} is reported as valid and the formatted output shows only "a": 2. Integers with more than about 16 digits can be rounded in the formatted copy: 1234567890123456789 becomes 1234567890123456800. The formatted output uses two-space indentation, and the Copy button copies it, or the error text when the input is invalid. To shrink valid JSON, use the JSON Minifier, and for JSON that will not parse, the JSON Formatter & Toolkit has a Repair button.