How to Fix Invalid JSON
JSON syntax errors are frustrating but almost always simple to fix once you know what to look for. This guide covers the 8 most common reasons JSON fails to parse, with exact before/after examples for each one and a free validator to find errors instantly.
{
'name': 'Alice',
age: 30,
"city": "New York",
}Step 1 — Find the Error Line
Before fixing, you need to know where the error is. Paste your JSON into the JSON Validator — it reports the exact line and character position of the first syntax error.
Note: JSON parsers stop at the first error. Fix one error, re-validate, and repeat until the document is clean. There may be multiple errors hidden behind the first one.
The 8 Most Common JSON Errors
These errors account for over 95% of all JSON validation failures:
JSON requires double quotes for all strings and keys. Single quotes are valid JavaScript but not valid JSON.
{'name': 'Alice'}{"name": "Alice"}Remove the comma after the last item in an object or array. Most editors can detect this with a JSON linter.
{"a": 1, "b": 2,}{"a": 1, "b": 2}Every key in a JSON object must be wrapped in double quotes. JavaScript objects allow unquoted keys — JSON does not.
{name: "Alice", age: 30}{"name": "Alice", "age": 30}JSON does not support comments of any kind — neither // nor /* */. Remove all comments before parsing.
{"key": "value" // a comment}{"key": "value"}JSON has no undefined or NaN. Replace them with null, or omit the key entirely if the value is not applicable.
{"score": NaN, "result": undefined}{"score": null, "result": null}Each key-value pair in an object and each element in an array must be separated by a comma.
{"a": 1 "b": 2}{"a": 1, "b": 2}Every opening bracket [ and brace { must have a matching closing bracket ] and brace }. Use a beautifier to reveal the nesting structure.
{"users": [{"id": 1}{"users": [{"id": 1}]}Numbers should be unquoted (42) and strings should be quoted ("99"). Mixing them causes type errors in most parsers.
{"count": "42", "label": 99}{"count": 42, "label": "99"}Tips to Prevent JSON Errors
Validate and Fix Your JSON Now
Paste your JSON and get the exact error line instantly — free, no sign-up.
Open JSON Validator