Trailing comma in JSON

Trailing commas are allowed in some JavaScript contexts, but not in standard JSON. One extra comma at the end of an object or array is enough to break parsing.

Broken example

{
  "name": "Ada",
}

Corrected example

{
  "name": "Ada"
}

Why this error happens

Trailing commas usually appear when developers copy object syntax from JavaScript or edit a list and forget to remove the old separator from the final item.

How to fix it

  1. Locate the last item in each object or array.
  2. Remove any comma that comes directly before a closing brace or bracket.
  3. Validate the JSON again.
  4. Format the fixed result to confirm the structure.

FAQ

Can arrays have trailing commas in JSON?

No. Trailing commas are invalid in both arrays and objects.

Why does JavaScript sometimes allow them?

Because JavaScript object syntax and JSON are related but not identical. JSON is stricter.

What is the fastest way to spot one?

Format the payload or inspect the character right before the closing brace or bracket.

Should I use a validator after removing it?

Yes. Validate again to make sure there are no additional syntax issues.