Fix JSON trailing comma

A trailing comma after the last element in a JSON object or array causes a parse error. JSON does not allow trailing commas.

Trailing commas are valid in modern JavaScript and many config formats, but **not** in JSON (RFC 8259). Parsers fail at the comma because they expect another key or value.

This is one of the most common copy-paste errors when moving from JS/TS or JSONC into strict JSON.

Common causes

  • Comma after the final property in an object.
  • Comma after the last element in an array.
  • Editor “format on save” that matches JS style and keeps a trailing comma.

How to narrow it down

  • The error often points at the comma or the closing `}` / `]`. Remove the comma only for the last element at that nesting level.
  • If you have nested objects, check each level — fixing one trailing comma may reveal another.

Examples

Invalid
{
  "a": 1,
}

Comma after 1 when it is the last key.

Valid
{
  "a": 1
}

No comma after the last property.

How to fix

  • Delete the comma after the last element at the same brace depth as the error.
  • Run your file through the JSON validator after each change.
  • In teams, enforce JSON with CI or pre-commit hooks so trailing commas never reach production.

Use our tool

Validate JSON

Advertisement

All guides