JSON Repair
Developer Guide

Fix Broken JSON Instantly — Trailing Commas, Unquoted Keys, Smart Quotes

JSON parse errors are frustrating because the error messages rarely tell you what actually went wrong. This guide covers every common way JSON breaks, shows you the exact before/after, and gives you a one-click repair tool for when you just need it fixed now.

April 29, 2026
9 min read
PDF Mavericks Team

Trailing Commas

This is the number one source of broken JSON. JavaScript objects allow trailing commas since ES5, which means any JSON exported from a JS file or config system may carry them. Standard JSON (RFC 8259) rejects trailing commas entirely.

Trailing comma in an object

BROKEN
{ "name": "Jane", "role": "admin", }
FIXED
{ "name": "Jane", "role": "admin" }

Remove the comma after the last property. JSON objects and arrays cannot have a comma after the final item.

Trailing comma in an array

BROKEN
{ "tags": ["json", "api", "rest",] }
FIXED
{ "tags": ["json", "api", "rest"] }

The comma after "rest" is invalid. Array elements follow the same rule — no trailing comma.

If you write TypeScript/JavaScript and need trailing commas in your source code (common in Prettier config), use JSONC format or convert to plain JSON before sharing.

Unquoted Keys

JavaScript objects allow unquoted keys. JSON does not. If you've copied an object literal from a JavaScript file, the keys won't have quotes.

Unquoted keys (JavaScript object literal)

BROKEN
{ name: "Jane", age: 30, active: true }
FIXED
{ "name": "Jane", "age": 30, "active": true }

Every key in JSON must be wrapped in double quotes. This is one of the most meaningful differences between JSON and JavaScript object notation.

The fix is mechanical: wrap each key in quotes. A repair tool handles this automatically. If you're doing it manually, be careful with keys that contain hyphens or spaces — they still need quotes in JSON.

Single Quotes

Python developers frequently hit this one. Python's str(dict) and repr() output uses single quotes. JSON only accepts double quotes.

Single-quoted strings (Python repr output)

BROKEN
{'name': 'Jane', 'active': True, 'count': 5}
FIXED
{"name": "Jane", "active": true, "count": 5}

Two problems here: single quotes need to become double quotes, and Python boolean True becomes JSON true (lowercase). Use json.dumps() in Python instead of str() to get valid JSON.

Smart Quotes from Word / Google Docs

Word processors auto-convert straight quotes (") to typographic "smart quotes" ( and ). When you copy JSON from a document that was edited in Word or Google Docs, these curly characters break every parser.

Smart quotes from a word processor

BROKEN
{“name”: “Jane Doe”, “role”: “admin”}
FIXED
{"name": "Jane Doe", "role": "admin"}

The curly open-quote (“) and close-quote (”) characters are not valid JSON string delimiters. Replace them with standard straight double-quote characters (ASCII 0x22).

This is particularly painful because smart quotes look almost identical to regular quotes in most fonts. The error message (Unexpected token ‘ at position 0) is the tell.

Comments in JSON

JSON has no comment syntax. None. Not //, not /* */, not #. If you've copied a JSONC (JSON with Comments) config file — common in VS Code settings, TypeScript configs, and ESLint configs — you need to strip the comments before parsing.

JSONC with comments (VS Code-style)

BROKEN
{ // Database settings "host": "localhost", "port": 5432, /* default port */ "name": "mydb" }
FIXED
{ "host": "localhost", "port": 5432, "name": "mydb" }

Remove all comment lines and inline comments. If you need comments in your config, keep it as .jsonc and use a JSONC parser (like strip-json-comments) before passing to JSON.parse().

Missing Commas Between Properties

Less common but happens when JSON is generated by string concatenation or edited manually:

Missing comma between properties

BROKEN
{ "name": "Jane" "role": "admin" }
FIXED
{ "name": "Jane", "role": "admin" }

Every property in a JSON object must be separated by a comma, except for the last one. A missing comma triggers a SyntaxError pointing to the line after the gap.

Truncated / Incomplete JSON

APIs that hit size limits, log truncation, or clipboard paste errors can leave you with JSON that simply ends mid-way. The jsonrepair library (used in our Repair tab) can often close open strings, arrays, and objects intelligently.

Truncated JSON (missing closing brackets)

BROKEN
{"users": [{"name": "Jane", "id": 1}, {"name": "Bob"
FIXED
{"users": [{"name": "Jane", "id": 1}, {"name": "Bob"}]}

Repair tools close open structures at the end. The repaired output is best-effort — always verify that the inferred structure matches your intent before using the result.

How to Read JSON Error Messages

JavaScript's JSON.parse() throws SyntaxError with position information. Here's a quick decoder:

Unexpected token } at position 47
Cause: Trailing comma before the closing bracket
Fix: Remove the comma at position ~45
Unexpected token ‘ at position 0
Cause: Smart quote (curly quote) instead of double quote
Fix: Replace all smart quotes with straight quotes
Unexpected token a at position 12
Cause: Unquoted key — parser hits the letter and stops
Fix: Wrap keys in double quotes
Unexpected end of JSON input
Cause: Truncated JSON — file cut off before closing
Fix: Close open arrays and objects
Unexpected token / at position 5
Cause: Comment in JSON (// or /* */)
Fix: Remove all comments

Repair JSON in One Click

Paste your broken JSON, hit the Repair tab. Our formatter uses the jsonrepair library to fix trailing commas, unquoted keys, single quotes, smart quotes, missing brackets, and more — browser-side, no data sent anywhere.

Open JSON Repair Tool