JSON Validator
Check whether JSON is valid and see the line and column of the first error.
The tool only checks whether the text follows JSON syntax. Validate JSON runs the browser's JSON.parse; on success it shows structure stats, on failure the error message and a position. Data stays in the page. It does not check structure or schemas, so JSON missing a required key still counts as valid.
| Input | Keys | Max depth | Arrays | Objects |
|---|---|---|---|---|
| Sample JSON | 8 | 2 | 1 | 2 |
{"a":1} | 1 | 1 | 0 | 1 |
{"user":{"id":1,"tags":["a"]}} | 3 | 3 | 1 | 2 |
[[1,[2]]] | 0 | 3 | 3 | 0 |
42 | 0 | 0 | 0 | 0 |
Keys are counted in nested objects too. Depth counts the deepest level that holds a value, with the outermost level as 0; an empty {} is 0. A lone 42 is valid JSON.
Six mistakes that come up most
| Invalid | Fixed |
|---|---|
[1, 2, 3,] | [1, 2, 3] |
{a: 1} | {"a": 1} |
{"msg": "He said "hi""} | {"msg": "He said \"hi\""} |
{"path": "C:\data"} | {"path": "C:\\data"} |
{"ok": True} | {"ok": true} |
{"n": NaN} | {"n": null} |
Below the error message you get a line such as Position: Line 3, Col 8. A missing closing bracket is reported at the very end even though the fix is somewhere earlier. If the named line looks fine, check the commas and brackets before it, and expand the text with the JSON formatter to see how brackets pair up. The position line may be missing in Firefox and Safari.
A key repeated twice passes without error and only the last value is kept. If a log file fails on its second line, it is JSON Lines and each line must be checked separately.