{}JSON FYI

Trailing commas in JSON, explained

Why every parser rejects them, when JSON5/JSONC do allow them, and how to clean them up.

·4 min read

A trailing comma is the comma after the last element of an array or object:

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

RFC 8259 forbids it. Every compliant parser rejects it. JavaScript and Python allow it in their literal syntax — that's where the muscle memory comes from.

Quick fix

Remove the comma before each ] and }. The JSON FYI linter highlights every offender with line and column.

If you really want them

Use JSON5 or JSONC, both of which accept trailing commas. Pick one and configure your parser accordingly.

Find the problem with the JSON linter →

The linter surfaces trailing commas, duplicate keys, and other common issues with line and column numbers.

Open JSON Linter →

Frequently asked questions

Why is this error so common?+

Diff-friendliness — many style guides put a trailing comma in JS/Python code so adding a new line doesn't touch the previous one. JSON unfortunately doesn't allow it.

Related tools & guides