Cryonel

JSON Trailing Comma Error, Explained

JSON does not allow a comma after the last element of an object or array. It's a strict, deliberate part of the spec — not a parser bug.

What triggers it

{
  "name": "Ada",
  "role": "admin",
}

That trailing comma after "admin" is invalid. The same applies to arrays: [1, 2, 3,] fails to parse.

Why JSON is stricter than JavaScript here

JavaScript object and array literals do allow a trailing comma — it was added specifically so version control diffs stay clean when you add a new last item. JSON, defined independently as a data interchange format (RFC 8259), never adopted that allowance. The two look similar but are governed by different grammars, and this is the most common place the difference bites people who write JSON by hand or generate it with string templates.

How to avoid it

Related Tools