August 12, 2026

JSON Trailing Comma Error

JSON Trailing Comma Error

One of the most annoying errors in JSON is the trailing comma error: Unexpected token } in JSON at position X.

What is a trailing comma?

A trailing comma is a comma placed after the final element of a list or object.

Valid in JavaScript, INVALID in JSON:

{
  "name": "John",
  "age": 30, // <--- This comma breaks the JSON!
}

Why doesn't JSON allow it?

The creator of JSON, Douglas Crockford, strictly defined the spec to forbid trailing commas to ensure maximum portability across all programming languages, some of which had parsers that would fail on trailing commas.

How to fix it

Simply remove the comma before the closing brace } or bracket ]. You can use our JSON Validator to instantly find exactly which line the offending comma is on.