JSON WalletPrivacy-first JSON & API workspace

Fix a Trailing Comma in JSON

All languages ยท JSON error

โ† All tools

Unexpected token } in JSONUnexpected token ] in JSONTrailing commaSyntaxError: Bad control character / trailing comma

Interactive tool

Try json repair tool

Runs locally in your browser
Repair JSON runs automatically
Repaired and verified as valid JSON
{
  "a": 1,
  "b": 2,
  "list": [
    "x",
    "y"
  ]
}

Need the repaired JSON beside an editable tree view?

The full editor opens with the broken and repaired versions side by side.

What causes it

Unlike JavaScript, the JSON grammar does not permit a comma after the final item in an object or array. When a parser reaches the closing } or ] and the last thing it saw was a comma, it expects another value and fails instead.

This is the single most common JSON mistake because most code editors, linters, and the JavaScript engine itself tolerate trailing commas โ€” so the habit carries over into JSON, where it is illegal.

How to fix it

  1. Find the comma immediately before a closing } or ].
  2. Delete that comma โ€” every item needs a comma between it and the next, but not after the last.
  3. Watch for the same mistake in nested objects and arrays.
  4. Or paste the whole document into JSON Wallet and click Repair to strip every trailing comma at once.

Before and after

Broken:

{
  "a": 1,
  "b": 2,
}

Fixed:

{
  "a": 1,
  "b": 2
}

Want to fix your own JSON instead of the example? Open the editor, paste it in, and click Repair โ€” it runs entirely in your browser.

Frequently asked questions

Why does JavaScript allow trailing commas but JSON does not?

JavaScript relaxed its grammar for developer convenience. JSON deliberately keeps a strict, minimal grammar so every parser in every language behaves identically. A trailing comma is valid JS but invalid JSON.

Is there a JSON format that allows trailing commas?

Yes โ€” JSON5 and JSONC (used by VS Code) allow them, but standard parsers such as JSON.parse() and Python's json will still reject them. Remove the comma for maximum compatibility.


Related JSON errors

For a full reference of JSON mistakes, read Common JSON errors and how to fix them.

Press โŒ˜ K for commands