Remove trailing comma from 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 — here is how to find and remove them fast.

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”, the fix is almost always the same: delete the comma that comes right before a closing `}` or `]` — a JSON validator shows the exact line and column.

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