Article

Remove Trailing Comma in JSON

JSON does not allow trailing commas. Learn why and how to find and remove them. Use a JSON validator to get the line number, then fix the syntax.

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.