JSON Repair: Fix Broken JSON

Paste JSON that will not parse, from a log, a config file or an AI reply. DevPocket repairs what is safe to repair, lists every change and refuses to guess the rest.

Loading the tool. It runs entirely in your browser...

What it repairs, and what it will not guess

Each repair is listed with its line and column. The tool fixes: a BOM or invisible characters, markdown code fences and prose around the JSON, // and /* */ comments, single or curly quotes, unquoted keys, trailing commas, missing commas, Python None, True and False, undefined, NaN and Infinity, raw line breaks inside strings, and brackets left open when the text was cut off.

Changing a value is the risky part, so those cases are named. NaN and Infinity have no JSON form: they become null or a string, as you choose, and the list says so. Everything else keeps its value; strings, numbers and key order are copied, not re-parsed.

It stops with a line and column instead of guessing when the damage is ambiguous: an unquoted word used as a value, a key with no value, a missing colon, an invalid escape such as \d, or several JSON documents in one input. Valid JSON is returned with zero changes.

Worked example

Input, as pasted from a chat reply:

Here is the JSON:
```json
{
  // user record
  'id': 7,
  name: "Ann",
  "active": True,
  "tags": ["a" "b",],
  "address": {"city": "Paris"
```

Nine changes, in order:

1:1  Removed the opening markdown code fence and the text before it: "Here is the JSON:"
4:3  Removed a // comment
5:3  Converted a single-quoted string to a double-quoted one
6:3  Added quotes around the key name
7:13 Replaced Python True with true
8:15 Inserted a missing comma between two elements
8:19 Removed a trailing comma
10:1 Removed the closing markdown code fence and everything after it
10:1 Added 2 missing closing brackets at the end: } }

Result, with the verdict Valid JSON after repair:

{
  "id": 7,
  "name": "Ann",
  "active": true,
  "tags": [
    "a",
    "b"
  ],
  "address": {
    "city": "Paris"
  }
}

Check the result before you use it

A repair makes text parse; it cannot know what you meant. A cut-off reply is closed where it ends, so data after the cut is gone, and the change list shows where. Read the Before and after diff, then paste the output into the JSON formatter or compare two versions with JSON diff.

Frequently asked questions

Is a repaired result always what the author meant?

No. It is valid JSON that follows from the listed changes. Closing a truncated reply, for instance, keeps only what was written before the cut.

Why does it refuse some inputs?

When two readings are possible, such as an unquoted word that could be a missing string or a typo, any pick would be a guess. The tool reports the position and leaves the decision to you.

Does it change my numbers or strings?

No. Numbers and strings are copied as written, apart from the listed quote and escape fixes, which keep the same text. The only value changes are NaN, Infinity, undefined, and the Python None, True and False.

Can it fix JSON Lines or several documents?

No. It stops and names the position of the second document. Repair each line on its own.

What if the JSON is already valid?

You get it formatted, the verdict says nothing was changed, and the list of fixes is empty.

Is my data uploaded?

No. Repair runs in your browser, so logs and API replies stay on your device.