Remove Trailing Comma in JSON
A trailing comma is a comma after the last element in an array or the last property in an object. JavaScript allows it; JSON does not. If your JSON has a trailing comma, parsers will throw. This guide explains where they appear and how to remove them using a JSON validator to find the line.
Why JSON Doesn't Allow Trailing Commas
The JSON spec (ECMA-404 and RFC 8259) explicitly disallows a comma after the last value in an array or the last pair in an object. So [1, 2, 3,] and {"a": 1,} are invalid. This keeps the grammar simple and avoids ambiguity in older parsers. Modern JavaScript allows trailing commas in arrays and objects; JSON does not.
Where Trailing Commas Appear
Common places: after the last element in an array (..., "last",]), after the last property in an object ("key": value,}), or in nested structures. Copy-paste from JavaScript or from configs that allow trailing commas (e.g. some JSONC or YAML converters) can introduce them.
How to Find and Remove Them
Paste your JSON into our JSON validator. If there's a trailing comma, we report the error and the line (and column when available). Go to that line, remove the comma after the last item before ] or }, and validate again. Repeat until valid. You can also use our JSON formatter after fixing—formatting won't remove commas but will make structure easier to read.
Example: Invalid vs Valid
// Invalid (trailing comma)
{"name": "Alice", "age": 30,}
// Valid
{"name": "Alice", "age": 30}
Summary
JSON does not allow trailing commas. Find them with a JSON validator that shows line/column, then delete the comma before the closing ] or }. For more on JSON errors see fix unexpected token in JSON and our developer tools.