Trailing comma
Also called dangling comma
A trailing comma is a comma after the last item in a JSON array or object, like [1, 2,] or {"a": 1,}. JSON does not allow it, so strict parsers reject both examples. JavaScript and JSON5 accept trailing commas, which is why they often slip into hand-edited JSON.
In more detail
A trailing comma is a comma after the last item in an array or object, as in [1, 2,] or {"a": 1,}. JSON does not allow it. In RFC 8259 every comma must be followed by another value or member.
Parsers reject it with different messages. Current Chrome and Node.js say Expected double-quoted property name for an object and Unexpected token ']' for an array. Older Python versions say Expecting property name enclosed in double quotes, and Python 3.13 says Illegal trailing comma before end of object.
The habit comes from JavaScript, Python and most modern languages, which allow trailing commas in source code. JSON5 and the JSONC dialect used by tsconfig.json accept them too, so a file that works in one tool can fail in another.
To fix it, delete the last comma. For many files, a JSON repair tool or a JSON5 to JSON converter removes every trailing comma at once.
Example
// Invalid: trailing commas
{ "roles": ["admin", "editor",], "active": true, }
// Valid
{ "roles": ["admin", "editor"], "active": true }Try it
Learn more in the guide How to fix JSON syntax errors and JSON.parse SyntaxError.
← Back to Trailing comma in the JSON glossaryUpdated 2026-10-01