Ffile2fix
Sign in Get started

How to Fix Broken JSON: Common Errors and Quick Repairs

Malformed JSON has a way of failing at the worst possible moment — a third-party API returns a truncated response, a hand-edited config file gets a stray comma, or a log export gets cut off mid-write. The good news: JSON's syntax is simple enough that most breakage falls into a small, predictable set of mistakes, and most of them are quick to fix once you know what you're looking for.

The five JSON errors you'll hit 90% of the time

1. Trailing commas

JSON does not allow a comma after the last item in an object or array — even though it's legal in JavaScript, which trips up a lot of people copying data between the two.

{ "name": "file2fix", "active": true, }  ❌ trailing comma before }
{ "name": "file2fix", "active": true }   ✅ correct

2. Unescaped quotes inside strings

A double quote inside a string value has to be escaped as \". This is the classic failure mode when JSON gets built by naive string concatenation instead of a proper serializer.

{ "note": "he said "hello"" }     ❌ breaks parsing
{ "note": "he said \"hello\"" }   ✅ correct

3. Single quotes instead of double quotes

JSON requires double quotes for both keys and string values — always. Single quotes are valid in JavaScript object literals but not in JSON itself.

{ 'name': 'file2fix' }   ❌ invalid JSON
{ "name": "file2fix" }   ✅ correct

4. Unbalanced brackets or braces

Usually caused by a truncated API response or a copy-paste that missed the last few characters. The parser error ("Unexpected end of JSON input") is your clue — it means the structure never closed.

5. Missing commas between properties

Easy to miss visually, especially in deeply nested or minified JSON, since the two tokens on either side of the gap look perfectly valid on their own.

{ "a": 1 "b": 2 }   ❌ missing comma
{ "a": 1, "b": 2 }  ✅ correct

Why "just read the error message" often isn't enough

Most JSON parsers report only the position of the first error, not every problem in the file. Fix that one and re-run, and you'll often hit a second, unrelated error a few lines later — which makes manually fixing a large malformed file (say, a multi-thousand-line API log dump) slow and frustrating one error at a time.

The faster path: automated repair

For anything beyond a two-line fix, it's faster to run the file through a repair tool that finds and corrects all of the common failure patterns — missing commas, unbalanced brackets, unescaped quotes — in one pass, rather than playing whack-a-mole with a linter. Our Broken JSON Auto-Repair tool was built specifically for this: paste in malformed JSON from a broken API response, a corrupted export, or a hand-edited config, and it fixes the structural issues and hands back valid JSON you can actually use.

Preventing it next time

  • Always generate JSON with a real serializer (json_encode() in PHP, JSON.stringify() in JS) — never string-concatenate it by hand.
  • If you're hand-editing config files, run them through a validator before deploying, not after something breaks in production.
  • When consuming a third-party API, don't assume the response is always well-formed — wrap your parsing in a try/catch and log the raw response so you have something to repair if it ever comes back malformed.

Try the related tools

More guides

File Conversion

How to Convert JSON, CSV, XML, Markdown, and Images Privately

Choose the right converter for structured data, documents, or images — and learn why browser-only conversion is safer for sensitive files.

Security

How to Share a Repaired File Without Exposing Your Server

A safe handoff checklist for repaired files: inert storage names, forced downloads, expiry, access expectations, and the mistakes to avoid.

SEO

Technical SEO Checklist for Online Tool Pages

How tool directories can earn useful search traffic without creating thin pages: clear URLs, intent-led copy, schema, internal links, and honest indexing.

ZIP & Archives

How to Fix a Corrupted ZIP File: 5 Methods That Actually Work

From a quick integrity check to multi-pass deep repair — a practical, no-nonsense guide to recovering a damaged ZIP archive, matched to what actually broke.

Debugging

Common PHP Fatal Errors Explained (and How to Actually Fix Them)

Undefined function, class not found, memory exhausted, execution time exceeded — what these PHP fatal errors really mean, and how to read a stack trace correctly.

Security & Config

.env File Best Practices: How to Validate and Secure Your Environment Variables

Silent syntax errors, missing variables, and accidentally committed secrets — a practical audit checklist for your .env file before it causes a production incident.

WordPress

How to Read Your WordPress debug.log (and Actually Fix What It Tells You)

How to turn on WordPress debug logging, tell fatal errors from harmless deprecation notices, and identify exactly which plugin or theme is actually responsible.