</>
ValidateHTML

Trailing Comma in JSON

A trailing comma is a comma placed after the last property in an object or the last element in an array. JavaScript and many programming languages allow this, but JSON strictly forbids it. The parser sees the comma and expects another value, but finds a closing bracket instead.

Why It Matters

The JSON document fails to parse entirely. This is especially common when developers copy JavaScript objects into JSON files without cleaning up the syntax, or when removing the last property and forgetting to also remove its preceding comma.

Code Examples

Invalid JSON
{
  "name": "Alice",
  "age": 25,
  "hobbies": [
    "reading",
    "coding",
  ],
}
Valid JSON
{
  "name": "Alice",
  "age": 25,
  "hobbies": [
    "reading",
    "coding"
  ]
}

How to Fix

  • 1Remove the comma after the last property in every object.
  • 2Remove the comma after the last element in every array.
  • 3Check nested structures carefully. Trailing commas often hide inside deeply nested objects.
  • 4Use a JSON validator to spot trailing commas automatically before deploying.

Check Your JSON Now

Our JSON validator detects this error automatically and shows the exact line and column.

Open JSON Validator
Recommended

Hostinger Fast & Affordable Web Hosting

Deploy clean, validated JSON APIs on reliable hosting.

Get 80% Off Hosting →

Related JSON Errors

View all JSON errors