← Back to tool

Clean · Fix commas · Validate

Remove Trailing Commas from JSON

Updated: June 2026

A trailing comma — the comma after the last item in an object or array — is the single most common reason JSON fails to parse. It is allowed in JavaScript, so it slips in constantly, but the JSON spec forbids it. This tool strips those stray commas and gives you valid JSON back.

Remove Trailing Commas →

Free · No upload · Instant in the browser

What a trailing comma looks like

A trailing comma sits between the final value and the closing brace or bracket, where there is no next item to separate. Both of these are invalid JSON purely because of that last comma:

{
  "a": 1,
  "b": 2,        // <- trailing comma
}

[ "x", "y", "z", ]   // <- trailing comma

Remove the offending commas and both become valid. The fix is trivial once you know where to look, but in a large document spotting which comma is the problem can take longer than it should.

Why it happens so often

JavaScript, Python, and most modern languages permit trailing commas in their literals because it makes editing easier: you can reorder or append lines without fixing the comma on the line above. That habit is so ingrained that developers add them to JSON by reflex. Code generators and templating systems produce them too, especially when a loop appends "item", for every element and never trims the last one. The result is JSON that looks right and parses wrong.

Strip them safely

The naive fix — delete every ,] and ,} with a text editor — works until a comma like that appears inside a string value, at which point you have silently corrupted your data. A safe remover is string-aware: it only deletes a comma when it truly precedes a closing bracket in the structure, never one that lives inside quotes. Turn on Repair here and the tool removes trailing commas correctly, along with comments and other common mistakes, then re-formats clean JSON.

  • Handles commas before both } and ].
  • Ignores commas inside string values.
  • Fixes every occurrence in one pass, however deeply nested.

Confirm with the validator

After stripping the commas, validate to be sure nothing else is wrong. If a different error remains, the validator reports its line and column so you can fix it directly. The whole cycle — repair, format, validate — runs in your browser with no upload, so even JSON that contains tokens or private fields stays on your machine. The cleaned, comma-free result is ready to copy straight back into your code or config.

Frequently asked questions

How do I remove a trailing comma from JSON?

Paste the JSON and enable Repair. The tool strips commas that sit right before a closing brace or bracket and outputs valid JSON.

Why is a trailing comma invalid in JSON?

The JSON spec only allows a comma between two items. A comma with nothing after it before a closing bracket is a syntax error, even though JavaScript permits it.

Will it remove commas inside my strings?

No. The remover is string-aware and only deletes structural trailing commas, leaving commas inside string values untouched.

Is the fix done privately?

Yes. It runs locally in your browser, so your JSON is never uploaded.