JSON QuickFix › Fix trailing commas in JSON

Fix trailing commas in JSON

A comma after the last item in an object or array, like [1, 2, 3,], is fine in JavaScript but breaks JSON.parse. Paste your JSON and press Quick Fix: every trailing comma is removed and listed with its line number.

Input

Paste some JSON, drop a .json file, or load the sample to get started.
Advertisement

Why trailing commas break JSON

The JSON grammar only allows a comma between two values. A comma followed directly by } or ] means another value was expected, so every strict parser stops there. JavaScript, TypeScript, Python and most config formats accept the extra comma, which is why it sneaks in so often when JSON is edited by hand or generated from code.

What the error looks like

  • Chrome / Edge / Node.js, object: Expected double-quoted property name in JSON at position 7
  • Chrome / Edge / Node.js, array: Unexpected token ']', "[1,2,]" is not valid JSON
  • Older browsers: Unexpected token } in JSON at position 7
  • Firefox: JSON.parse: expected double-quoted property name or unexpected character, with a line and column
  • Python 3.13+: JSONDecodeError: Illegal trailing comma before end of object (or of array); older Python: Expecting property name enclosed in double quotes or Expecting value

How to fix it

  1. Paste the JSON into the input pane, or open the file.
  2. Press Quick Fix. Each removed comma is listed with its line.
  3. Copy or download the valid result, or press Replace input with fixed JSON to keep editing.

To prevent it, let your language's serializer write the file (JSON.stringify, json.dumps) instead of building JSON by hand, and turn on a linter rule such as comma-dangle for files that must stay strict JSON.

Advertisement

Frequently asked questions

Are trailing commas allowed in JSON?

No. The JSON specification (RFC 8259) does not allow a comma after the last element of an object or array. JSON5 and JSONC allow them, but standard parsers such as JSON.parse and Python's json module reject them.

Will removing the comma change my data?

No. A trailing comma carries no value, so deleting it leaves every key and value exactly as it was.

Can it fix many trailing commas at once?

Yes. Quick Fix removes every trailing comma in the document in one pass and reports how many it removed and on which lines.