JSON Repair Tool Online

Fix Broken JSON
instantly, for free

Paste your invalid JSON and get valid output back. Automatically repairs trailing commas, unquoted keys, single quotes, JavaScript comments, and undefined values.

Repair JSON Now
🔧

6 Fix Transforms

Six sequential repairs handle the most common ways JSON breaks — in the right order to avoid conflicts.

Shows What Changed

After repair, the result is validated and formatted so you can see exactly what was fixed.

🤖

AI-Output Friendly

Handles the messy JSON that LLMs and APIs produce — JS comments, trailing commas, unquoted keys.

Six transforms applied automatically

Trailing Commas Removes commas before ] and } — the most common JavaScript-to-JSON mistake.
Unquoted Keys Wraps bare object keys in double quotes — fixes JSON written as JavaScript object literals.
Single Quotes → Double Quotes Converts 'value' to "value" throughout strings and keys.
JS-Style Comments Strips // line and /* block */ comments that are valid in JS5 but not JSON.
undefined → null Replaces bare undefined values with null — valid JSON's closest equivalent.
Format After Repair Once repaired, the JSON is fully formatted with syntax highlighting and a tree view.

Your data never leaves your device

Secure by architecture, not by policy

  • No backend server — there is nowhere for your data to go
  • No WebSocket, no fetch, no XHR for your JSON content
  • All repair transforms run entirely in your browser using pure JavaScript regex
  • Useful for sensitive API responses, config files, and tokens
  • No account, no login, no cookies tied to you

Related JSON tools

JSON Formatter Pretty-print JSON with syntax highlighting and a collapsible tree view.
JSON Validator Validate JSON against RFC 8259 with precise error locations.
JSON Diff Compare two JSON documents and highlight every added, removed, and changed field.
JSON Schema Validator Validate JSON data against a JSON Schema definition in the Schema tab.

Common questions answered

What types of broken JSON can the repair tool fix?

It fixes trailing commas, unquoted keys, single-quoted strings, JavaScript comments (//, /* */), and undefined values.

Is the JSON repair tool free?

Yes, completely free with no login required.

Does JSON repair send my data online?

No. Repair runs entirely in your browser — your JSON is never uploaded.

What if the repair tool can't fix my JSON?

The tool shows exactly what repairs it applied. If it can't fully repair, it shows the error location so you can fix it manually.

Can I use the repaired JSON in other tabs?

Yes. After repair, click 'Use in Format' to send it directly to the Format tab for pretty-printing.

What is JSON repair?

JSON repair automatically fixes common syntax errors that make a JSON document invalid. Real-world JSON often arrives broken: APIs return malformed responses, copy-paste introduces trailing commas, and hand-edited files accumulate single quotes, unquoted keys, and JavaScript comments. A repair tool applies transformations to produce valid JSON.

This tool applies six repair strategies in sequence: removing JavaScript comments (// and /* */), converting single quotes to double quotes, quoting unquoted keys, removing trailing commas, replacing undefined with null, and fixing unescaped control characters. Each repair is non-destructive — it modifies only the syntax, not the data values.

Repair broken JSON
Input
{
  // user data
  name: 'Alice',
  age: 30,
  active: undefined,
}
Output
{
  "name": "Alice",
  "age": 30,
  "active": null
}

Get the most out of this tool

Got broken JSON? Let's fix it.

Free forever. No signup. Works offline.

Open JSON Repair Tool

How automatic JSON repair works

JSON repair, also called JSON recovery or JSON fixing, is the process of transforming syntactically invalid JSON into valid JSON while preserving as much of the original data as possible. It is fundamentally different from validation — a validator only tells you what is wrong, while a repair tool also fixes it. The challenge is that JSON errors are often ambiguous: a missing closing brace could be fixed by adding one at the end, or by removing an extra opening brace somewhere in the middle. The repair algorithm must make a reasonable inference about which fix preserves the author's intent.

The most common repair case is trailing commas. When a developer builds a JSON string by hand or edits a JSON file, they often add a comma after the last element before closing a bracket. Standard JSON forbids this. The repair tool detects this pattern (a comma immediately followed by } or ]) and removes the excess comma, producing valid JSON in milliseconds.

Single-quoted strings are another very common issue. Developers familiar with Python or JavaScript sometimes write JSON-like data using single quotes: {'key': 'value'}. This is invalid JSON but has clear intent. The repair tool replaces single-quoted string delimiters with double quotes, correctly handling cases where the string content itself contains a single quote (which it escapes) or a double quote (which it already escapes).

Unquoted keys appear frequently in data copied from JavaScript console output or configuration files inspired by HJSON. A key like {name: "Alice"} has an unquoted identifier as a key, which is valid JavaScript but not JSON. The repair tool identifies bare identifiers in key position and wraps them in double quotes: {"name": "Alice"}.

JavaScript-style comments (//, /* */) sometimes appear in JSON that was originally JSONC (JSON with Comments) and was copy-pasted into a context expecting standard JSON. The repair tool strips both line comments and block comments before returning clean JSON. Similarly, JavaScript undefined values — which have no JSON equivalent — are converted to null, and NaN and Infinity values are also replaced with null since they are illegal in JSON.

Truncated JSON is a special repair case that arises frequently with large API responses. If a connection is interrupted mid-transmission, you receive a partial JSON document — perhaps a JSON array with only some elements, the final closing bracket missing. The repair tool detects unclosed structures and closes them at the deepest level, preserving the data already received and making the result parseable.

LLM-generated JSON often contains formatting errors because language models do not strictly follow the JSON grammar — they optimize for plausibility, not correctness. Common LLM JSON mistakes include markdown code fence markers (```json), prose before or after the JSON body, and occasional trailing commas or missing quotes on numeric keys. The repair tool handles all of these cases, making it especially useful in AI application pipelines.

When developers use this tool

Fixing LLM-generated JSON AI language models frequently produce JSON with minor formatting issues — trailing commas, extra text, or markdown fences. Pipe the LLM output through the repair tool before parsing in your application.
Recovering truncated API responses When a network timeout cuts off an API response mid-stream, the repair tool closes open structures and gives you a parseable subset of the data rather than a complete parse failure.
Cleaning hand-edited config files Developers editing JSON config files by hand frequently introduce trailing commas or remove required commas between entries. The repair tool fixes these without requiring you to hunt for the exact line.
Processing copy-pasted data Data copied from browser consoles, log viewers, or documentation often has single quotes, smart quotes, or extra line breaks. Repair normalizes this to standard JSON automatically.

What the repair tool fixes automatically

Additional frequently asked questions

How does the repair tool decide what to fix when JSON is ambiguous?

The repair algorithm applies a prioritized set of heuristics in order of most-to-least common errors. It first tries minimal changes (removing trailing commas, adding missing quotes) before considering structural changes (closing unclosed brackets). The goal is always to preserve the original data intent with the smallest possible transformation.

Can the repair tool fix JSON with completely wrong structure?

The repair tool handles common formatting problems well, but if the JSON structure is fundamentally different from valid JSON — for example, a CSV or XML file with a .json extension — it cannot produce meaningful output. It repairs damaged JSON, not incorrectly formatted non-JSON data.

Does repairing JSON change any values?

The repair tool only modifies structural elements (commas, quotes, brackets) and illegal value types (undefined → null). It never changes string content, numeric values, or boolean values. Your data is preserved; only the syntax is corrected.

Is the repair tool available as an API?

Yes. The REST API at api.jsonfmt.dev/repair accepts a JSON POST body and returns repaired JSON. This lets you integrate repair into server-side pipelines, preprocessing steps, or automated data ingestion workflows where you cannot run a browser.