How to Fix Trailing Comma in JSON Syntax Errors
Why This Error Happens
Unlike JavaScript object literals, the RFC 8259 JSON standard strictly forbids trailing commas after the last item in an object or array.
In JavaScript or Python dictionaries, a trailing comma is permitted and often preferred for git diffs. However, in JSON, a comma is strictly defined as a separator between two elements. Placing a comma after the final element causes standard JSON parsers to expect another element, resulting in an immediate parse error.
{
"id": 1,
"title": "Widget",
"active": true,
}{
"id": 1,
"title": "Widget",
"active": true
}Step-by-Step Fix
- 1Remove the comma after the last key-value pair in every object {}.
- 2Remove the comma after the last element in every array [].
- 3Paste your JSON into Format JSON Online, which automatically highlights and removes trailing commas.
Test and Auto-Fix Broken JSON Online
Paste your raw payload into our free, client-side JSON Validator. Detect syntax errors with line numbers and fix them in one click.
Open Free JSON ValidatorFrequently Asked Questions
Why does JSON not allow trailing commas?
Douglas Crockford intentionally omitted trailing commas from the JSON standard in 2001 to keep parser implementations minimal, unambiguous, and compatible across all programming languages.
Can JSONC or JSON5 allow trailing commas?
Yes! Formats like JSON5 and JSONC (JSON with Comments, used in VS Code settings) support trailing commas, but standard JSON APIs adhering to RFC 8259 will reject them.
Other Common JSON Errors
How to Fix 'Unexpected token < in JSON at position 0'
SyntaxError: Unexpected token < in JSON at position 0
How to Fix 'SyntaxError: Unexpected end of JSON input'
SyntaxError: Unexpected end of JSON input
How to Fix 'JSON keys must be double-quoted' Syntax Errors
SyntaxError: Expected property name or '}' in JSON