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
{
"name": "Alice",
"age": 25,
"hobbies": [
"reading",
"coding",
],
}{
"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 ValidatorHostinger — Fast & Affordable Web Hosting
Deploy clean, validated JSON APIs on reliable hosting.
Related JSON Errors
Unexpected Token in JSON
Learn why JSON throws an unexpected token error and how to fix it. Common causes include trailing commas, single quotes, and unquoted keys.
Missing Comma Between Properties
Learn how to fix the missing comma error in JSON. Every property pair must be separated by a comma.
Unquoted Property Keys in JSON
JSON requires all property names to be wrapped in double quotes. Learn how to fix unquoted key errors.