ErrorJSON · .json
JSON Trailing Comma — Why It Breaks Parsers
A JSON file containing a trailing comma after the last element in an array or object. This is valid in JavaScript but invalid in strict JSON (RFC 8259).
Why It Fails
The JSON specification (RFC 8259) does not allow trailing commas. While JavaScript engines tolerate them, JSON.parse() and most server-side parsers reject them with a syntax error. This is one of the most common JSON errors in API development.
Broken Example
{
"name": "Alice",
"age": 30,
"tags": ["developer", "writer",],
}Expected Error Behavior
JSON.parse() throws SyntaxError: Unexpected token } or Expected double-quoted property name. Python's json.loads() raises json.decoder.JSONDecodeError.
Affected Software
JSON.parse()Python json moduleJava JacksonGo encoding/jsonPHP json_decodePostgreSQL jsonb
How to Fix
Remove the trailing comma after the last element. Use a linter like jsonlint or ESLint with the json plugin to catch these automatically.