The most common JSON errors
These six cause nearly every “invalid JSON” error. The message under each one is exactly what the validator reports, and the fix is what the Repair button produces.
Trailing comma
JavaScript allows a comma after the last item; JSON does not.
{
"name": "Ada",
"admin": true,
}
Line 4, column 1: Trailing comma before } is not allowed
{
"name": "Ada",
"admin": true
}
Single quotes
Strings and keys must use double quotes.
{
'name': 'Ada'
}
Line 2, column 3: Property names must be double-quoted strings
{
"name": "Ada"
}
Unquoted key
Every key must be a double-quoted string, even simple ones.
{
name: "Ada"
}
Line 2, column 3: Property names must be double-quoted strings
{
"name": "Ada"
}
Comments
JSON has no comment syntax. Use JSONC or JSON5 files for configs that need comments.
{
// the user name
"name": "Ada"
}
Line 2, column 3: Property names must be double-quoted strings
{
"name": "Ada"
}
Missing comma
Usually caused by adding a line without a comma on the line above.
{
"name": "Ada"
"admin": true
}
Line 3, column 3: Expected ',' or '}' after property value, found '"'
{
"name": "Ada",
"admin": true
}
Python values
Python’s print() output isn’t JSON. Use json.dumps() instead.
{
"admin": True,
"manager": None
}
Line 2, column 12: Unexpected 'T': expected a value
{
"admin": true,
"manager": null
}
Other things that are not valid JSON
undefined,NaNandInfinity. Usenullor a string.- Numbers with leading zeros (
007), a leading+, or hex like0xFF. - Raw line breaks or tabs inside strings. They must be written as
\nand\t. - Escapes other than
\" \\ \/ \b \f \n \r \t \uXXXX.\'and\x41are invalid.
Valid doesn’t always mean safe to parse. Repeated keys and numbers like 9007199254740993 or
1e400 are legal JSON, but JavaScript’s JSON.parse drops or changes them. The validator
warns about both; see exactly what changes.
Validate JSON in code
function isValidJson(text) {
try {
JSON.parse(text);
return true;
} catch {
return false;
}
}
import json
try:
json.loads(text)
except json.JSONDecodeError as e:
print(f"line {e.lineno}, column {e.colno}: {e.msg}")
jq empty data.json && echo valid
Validating YAML instead? Use the YAML validator. Once your JSON is valid, the JSON formatter can pretty-print or sort it.
Frequently asked questions
How do I check if JSON is valid?
Paste it into the validator above. A green bar means it is valid JSON; otherwise you get the exact line and column of the first error with an explanation. From code, call JSON.parse in JavaScript or json.loads in Python inside a try block, or run jq . file.json on the command line.
What does “Unexpected token” mean in JSON.parse?
The parser found a character it did not expect at that position, such as a single quote, a trailing comma, a comment or an HTML page returned instead of JSON. “Unexpected token < in JSON at position 0” almost always means the server sent an HTML error page; check the response status and Content-Type.
Are comments allowed in JSON?
No. The JSON spec (RFC 8259) has no comments. Some tools accept “JSON with comments” (JSONC), like VS Code’s settings.json and tsconfig.json, but strict parsers reject them. The Repair button removes comments.
Are duplicate keys valid JSON?
RFC 8259 says keys “SHOULD be unique” but does not forbid duplicates, so most parsers accept them and silently keep the last value. That makes them a common source of bugs; the validator warns when it finds any.
Does it validate against a JSON Schema?
No, this checks syntax only: whether the text is well-formed JSON. Schema validation checks that the data has the right fields and types, which needs the schema itself and a library such as Ajv in JavaScript or jsonschema in Python.