What is a JSON validator?
A JSON validator checks whether text is well-formed JSON as defined by RFC 8259: one value made of objects, arrays, double-quoted strings, numbers, true, false and null, with commas and colons in the right places and every bracket closed. The difference between validators is what they tell you when the answer is no. This one reports every problem in a single pass, gives the line and column of each, explains it in plain words, and offers a repaired version.
How to validate JSON
- Paste the JSON or open a file. Validation runs automatically while you type; the Validate button simply re-checks and scrolls to the result.
- Read the status line. Green means valid, with line count, size, number of keys and nesting depth. Red means invalid, with the number of problems.
- Click a problem to put the cursor at that line and column. Problem lines are highlighted in red, warnings in yellow.
- Fix the problems by hand, or click Fix JSON to repair them and show a formatted result.
Errors and how they are reported
| What you wrote | What the validator reports | Valid JSON |
|---|---|---|
{"a": 1,} | Trailing comma before "}" | {"a": 1} |
{"a": 1 "b": 2} | Missing comma after the value on line 1 | {"a": 1, "b": 2} |
{"a": [1, 2} | Expected "]" to close the array opened on line 1 | {"a": [1, 2]} |
{'a': 'b'} | Strings must use double quotes | {"a": "b"} |
{a: 1} | Property names must be in double quotes | {"a": 1} |
{"n": 007, "x": .5} | Leading zeros; number starts with a decimal point | {"n": 7, "x": 0.5} |
{"ok": True, "v": None} | Booleans and null are lowercase | {"ok": true, "v": null} |
// comment | Comments are not allowed in JSON | remove the comment |
Finding the missing bracket
An unbalanced bracket is the hardest JSON error to find by eye, because parsers detect it far from where it happened. Take this file, where the env object lost its closing brace:
1 {
2 "name": "api",
3 "env": {
4 "LOG_LEVEL": "info",
5 "DB_POOL": 20
6 "ports": [8080]
7 }
A typical parser complains about line 6 (a missing comma) or about the end of the file. This validator reports the missing comma and the unclosed object, and puts a hint first: the object opened on line 3 is missing its closing "}". Add it at the end of line 5, before line 6. It reaches that conclusion because line 6 is indented exactly like line 3, so it cannot belong inside the object that line 3 opened. Fix JSON inserts the brace there and produces the intended structure, with ports at the top level rather than inside env.
Warnings that do not make JSON invalid
- Duplicate keys: allowed by the grammar but ambiguous; most parsers keep the last value.
- Byte-order mark: an invisible U+FEFF at the start of the file that RFC 8259 says must not be added and some parsers reject.
When the JSON is valid you can go straight to the JSON formatter, the minifier or the JSON diff.