What is a JSON validator?
A JSON validator checks whether a piece of text follows JSON syntax rules, so you know a program can parse it before you ship it in a config file or API request. This one gives a yes or no answer: either "Valid JSON." or the parser's error message pointing at the first problem it hit, usually with a line and column.
JSON's grammar is defined in RFC 8259 and ECMA-404. It's strict: double quotes only, no comments, no trailing commas. Those rules are easy to break when you write JSON by hand, which is where a validator earns its keep.
How to validate JSON
- Paste your JSON into the input box.
- Click Validate.
- Read the result. A green "Valid JSON." means the whole input parsed. Otherwise you'll see a red message starting with "Invalid JSON:" followed by the reason.
The input itself is never changed. If the input is empty or only whitespace, nothing is shown.
Worked example
This snippet looks harmless, but it has a trailing comma after the last item:
{"a":1,}
In Chrome and Edge the validator reports:
Invalid JSON: Expected double-quoted property name in JSON at position 7 (line 1 column 8)
Position 7 (counting from zero) is the closing brace, which is where the parser expected another key after the comma. Delete the comma and the result changes to "Valid JSON."
The message wording comes from your browser's JavaScript engine, so Firefox and Safari phrase it differently, and some errors (such as an unexpected ]) are reported without a line and column.
Common errors and what causes them
| Input | Message (Chrome/Edge) | Cause |
|---|---|---|
{"a":1,} |
Expected double-quoted property name | Trailing comma in an object |
[1,2,] |
Unexpected token ']' | Trailing comma in an array |
{name:"x"} |
Expected property name or '}' | Unquoted key |
{'a':1} |
Expected property name or '}' | Single quotes instead of double |
{"a":1} // c |
Unexpected non-whitespace character after JSON | A comment after the data |
{"a":1}{"b":2} |
Unexpected non-whitespace character after JSON | Two documents pasted together |
{"a":NaN} |
Unexpected token 'N' | NaN, Infinity and undefined aren't JSON |
| A raw tab inside a string | Bad control character in string literal | Tabs and newlines inside strings must be escaped as \t and \n |
The "two documents" case catches people working with JSON Lines (NDJSON) log files, where each line is a separate JSON document. Validate one line at a time instead of the whole file.
What "valid" does and doesn't tell you
The check is purely syntactic. A few results surprise people:
- Any single value is a valid document.
42,"hello",trueandnullall pass. RFC 8259 allows any JSON value at the top level, not only objects and arrays. - Duplicate keys pass.
{"a":1,"a":2}is reported valid. The RFC says names "SHOULD be unique" but doesn't forbid repeats, and most parsers silently keep the last one, which can hide a bug. - A leading byte order mark fails. The browser parser rejects the invisible U+FEFF character some editors put at the start of UTF-8 files.
- Comments and trailing commas fail, even though they're accepted in JSONC files such as VS Code settings and in JSON5. This tool validates standard JSON only.
- Structure isn't checked. A missing
"email"field or a number where you expected a string won't be flagged. For that you need JSON Schema.
Everything runs in your browser through JSON.parse, so the data you paste doesn't leave your device.
Related JSON tools
- JSON formatter: once your JSON is valid, indent it so you can read it. It reports the same errors.
- JSON minifier: strip whitespace for the smallest payload.
- Online JSON editor: edit with syntax highlighting instead of pasting back and forth.
- Code diff: compare two versions of a JSON file to see what changed.
Last updated