A practical guide to the most frequent JSON parsing errors, what causes them, and exactly how to fix them.
This is the most common JSON error. It usually means a character is out of place — often a JavaScript comment that slipped in.
// Wrong — JavaScript comment
{ "name": "test" // this is not allowed }
// Correct
{ "name": "test" }
JSON does not allow trailing commas. This trips up many developers coming from JavaScript.
// Wrong
{ "a": 1, "b": 2, }
// Correct
{ "a": 1, "b": 2 }
Certain characters inside strings must be escaped with a backslash: \", \\, \n, \t, \r.
// Wrong — unescaped backslash
{ "path": "C:\Users\name" }
// Correct
{ "path": "C:\\Users\\name" }
// Wrong
{ "price": $9.99, "count": 1,000 }
// Correct
{ "price": 9.99, "count": 1000 }