JSON Syntax Error Guide

How to Fix Trailing Comma in JSON Syntax Errors

SyntaxError: Trailing comma in JSON

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.

Invalid / Broken JSON
{
  "id": 1,
  "title": "Widget",
  "active": true,
}
Fixed / Valid JSON
{
  "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 Validator

Frequently 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