JSON Repair — Fix Broken JSON Online

This JSON repair tool automatically fixes the most common JSON syntax errors — trailing commas, JavaScript-style comments, single-quoted strings, and unquoted keys. All repair logic runs entirely in your browser using native JavaScript. Your JSON never leaves your device. Paste broken JSON on the left and get corrected, formatted output on the right instantly.

How JSON Repair Works

JSON repair identifies and corrects common syntax mistakes that cause JSON.parse() to throw a SyntaxError, without changing the underlying data. The repair process applies a series of targeted transformations before attempting to parse:

  • Trailing commas — removed before closing } or ]. The JSON spec (RFC 8259) explicitly forbids trailing commas even though JavaScript allows them. This is the most common error when JSON is written or edited by hand.
  • JavaScript comments — stripped before parsing. Both line comments (// ...) and block comments (/* ... */) are removed. Comments are common in configuration files but invalid in strict JSON.
  • Single-quoted strings — replaced with double quotes. JSON requires all strings to use double quotes; single quotes are a JavaScript-only convention that many developers apply out of habit.
  • Unquoted keys — property names without quotes (e.g., { key: "value" }) are wrapped in double quotes to produce valid JSON. Unquoted keys are valid in JavaScript object literals but not in JSON.

After all transformations are applied, the tool attempts JSON.parse() on the result. If parsing succeeds, the repaired and formatted JSON is shown alongside a summary of every change that was applied. If the input is too structurally broken to repair automatically — missing brackets, missing colons, fundamentally malformed input — the tool reports what it found so you can make targeted manual corrections.

Worked Example: Repairing a Broken JSON Object

A developer copies a JavaScript object literal from their codebase intending to use it as an API request body or config file, but it contains several issues that make it invalid JSON:

{
  // User profile
  name: 'Alice',
  age: 30,
  city: 'NYC',
  active: true,
}

This input has four problems: a JavaScript line comment, single-quoted strings, unquoted keys, and a trailing comma after the last property. The repair tool fixes all four in one pass:

{
  "name": "Alice",
  "age": 30,
  "city": "NYC",
  "active": true
}

The comment is stripped, single quotes become double quotes, all keys gain quotes, and the trailing comma after "active" is removed. The result passes JSON.parse() cleanly and retains all the original values. This pattern is extremely common when developers copy JavaScript config objects and need to use them in an API body, a .json config file, a database seed script, or a Postman / curl request.

Key Factors: When to Use Repair vs. Manual Editing

Automated repair works best for the class of errors introduced by manual editing or copying from JavaScript source code. Trailing commas, comments, single quotes, and unquoted keys are all artifacts of JavaScript syntax that developers habitually write but that the stricter JSON spec rejects. These are mechanical, unambiguous fixes — the repair tool can apply them reliably without any risk of changing the intended data.

Repair cannot fix structural problems: mismatched brackets or braces, missing colons between keys and values, duplicate keys, two adjacent values without a separating comma, or keys without values. These require understanding the intended structure of the data, which no automated tool can infer reliably. For these cases, the error message will indicate the approximate location of the problem so you can make a targeted manual correction.

After repairing, always verify that the output is semantically correct — that every value is what you intended, not just that the JSON parses successfully. The repair tool reports every transformation it applies so you can review each change. A repair that silently alters a key name or value would be more dangerous than one that fails loudly, so no speculative changes are ever made to data values.

Frequently Asked Questions

What JSON errors can this fix automatically?

The JSON repair tool fixes: trailing commas before } or ] (the most common error), JavaScript-style line comments (// ...) and block comments (/* ... */), single-quoted strings replaced with double quotes, and unquoted object keys (e.g. {key: "value"} → {"key": "value"}). After applying all fixes, it attempts JSON.parse and shows what was changed.

Will JSON repair change my data?

No. The repair tool only removes or corrects syntax issues — it never changes the actual values or structure of your data. Trailing commas, comments, and quote style are syntax artifacts; removing them does not alter what the JSON represents.

What causes trailing comma errors in JSON?

Trailing commas are allowed in JavaScript objects and arrays, but JSON (RFC 8259) explicitly forbids them. They appear when JSON is written by hand or generated by code that mimics JS syntax. For example: {"name": "Alice",} is valid JavaScript but invalid JSON. The repair tool removes these automatically.

Can I repair JSON with JavaScript comments?

Yes. JSON does not support comments (they were intentionally excluded from the spec), but developers often add // or /* */ comments when writing configuration files. The repair tool strips both line comments and block comments before attempting to parse.

Is my JSON sent to a server during repair?

No. All repair logic runs entirely in your browser using native JavaScript. Your JSON never leaves your device. You can verify this by opening DevTools → Network tab and watching for zero outbound requests while the tool runs.