What the validator checks
JSON is stricter than the JavaScript it looks like. A document is valid only if keys and strings use double quotes, items are separated by commas with none after the last item, every bracket and brace is closed, and values are one of: string, number, true, false, null, object or array.
Click Validate and the first error appears with its line and column; click the message to jump to that spot in the editor. Fix it and validate again, because a parser stops at the first problem, so later errors only show once earlier ones are gone. Once the document is valid, Format re-indents it.
The most common JSON errors and how to fix them
These are the mistakes that account for most invalid JSON. The wording is what this validator reports; other parsers phrase the same problems differently.
Trailing comma
Error: Trailing comma in object
Invalid
{
"a": 1,
"b": 2,
}Fixed
{
"a": 1,
"b": 2
}JSON, unlike JavaScript, does not allow a comma after the last item of an object or array. Delete it.
Single quotes
Error: Unexpected token "'"
Invalid
{
'name': 'Ada'
}Fixed
{
"name": "Ada"
}Only double quotes delimit strings and keys. Replace every single quote that delimits a string.
Unquoted key
Error: Unexpected token "a"
Invalid
{
name: "Ada"
}Fixed
{
"name": "Ada"
}Object keys must be strings in double quotes, even when they look like plain identifiers.
Missing comma
Error: Unexpected token "b"
Invalid
{
"a": 1
"b": 2
}Fixed
{
"a": 1,
"b": 2
}Two items next to each other need a comma between them. The reported position is the start of the second item.
Comments
Error: Unexpected token "/"
Invalid
{
// retry count
"retries": 3
}Fixed
{
"retries": 3
}JSON has no comment syntax. Remove the comments, or keep the notes in a separate field such as "_comment".
undefined or NaN
Error: No value found for key "a"
Invalid
{"a": undefined, "b": NaN}Fixed
{"a": null, "b": null}undefined, NaN and Infinity are JavaScript values, not JSON values. Use null, a number or leave the key out.
Validating JSON in your own code
In JavaScript, JSON.parse throws a SyntaxError on invalid input, so wrap it in try/catch when the text comes from a user, a file or a network response. In Python, json.loads raises json.JSONDecodeError with the line and column. When a program reports an "Unexpected token" error, paste the text here to see where it breaks.