How to Remove a Trailing Comma from a JSON Object

Removing a comma from a JSON object fixes the most common parse error: a trailing comma after the last property or array element. JSON does not allow trailing commas — open the validator with a broken sample and click Fix.

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.

If you searched for “removing comma from json object”, delete the comma right before a closing `}` or `]`, then click Fix in the JSON validator to auto-repair and re-validate.

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.

Advertisement

All guides