Skip to content
Devtoolry

JSON Repair

Fix broken JSON online: single quotes, trailing commas, comments, unquoted keys, truncated output and LLM answers in code fences. Shows every fix and a confidence score.

Runs in your browser · Nothing uploaded · No sign-up

Something not working, or missing a feature? Send feedback

About the JSON Repair

JSON Repair fixes text that is almost JSON: single quotes, unquoted keys, trailing commas, comments, Python True/None, missing commas and output that was cut off halfway. It also strips the Markdown fence and the chatty sentence an AI assistant puts around its answer, then lists every change it made and how sure it is of the result.

Everything runs in your browser, so your input is never uploaded to a server.

How to use the JSON Repair

  1. Paste the broken JSON, the model's whole answer, a JavaScript object or a Python dict.
  2. Read the message above the output: it lists what was fixed and a confidence score.
  3. Check the repaired JSON, especially if the confidence is low, then copy or download it.

Examples

Clean up an AI answer with comments and Python values

Input

Here is the config:
```json
{
  // service settings
  name: 'api',
  "port": 8080,
  "debug": True,
  "hosts": ["a.example.com", "b.example.com",],
}
```

Result

{
  "name": "api",
  "port": 8080,
  "debug": true,
  "hosts": [
    "a.example.com",
    "b.example.com"
  ]
}

The code fence and the sentence around it are removed, name gets quotes, 'api' gets double quotes, True becomes true, and the comment and the trailing commas are dropped.

Close JSON that was cut off

Input

{"user": {"id": 7, "name": "Ada", "roles": ["admin", "dev"

Result

{
  "user": {
    "id": 7,
    "name": "Ada",
    "roles": [
      "admin",
      "dev"
    ]
  }
}

The unterminated string, array and objects are closed. A lower confidence score tells you something was guessed: any data after the cut is missing.

Common mistakes

  • Trusting a repaired document blindly. A truncated answer is closed, not completed. If the last values matter, ask for the output again instead of using the repair.
  • Quotes inside strings. In "she said "hi" to me" the inner quotes are escaped by guessing where the string ends. Check such values, or escape the quotes at the source.
  • Several values at the top level. JSON Lines or two objects pasted one after another are combined into an array. If you meant only the first, delete the rest before repairing.

Works well with the JSON Repair

Frequently asked questions

How is the confidence score calculated?

Cosmetic fixes such as quotes, trailing commas and comments barely lower it, because they cannot change the meaning. Guesses, such as closing a document that was cut off, adding a missing colon or escaping a quote inside a string, lower it more. 100% means the input was already valid.

Can it repair JSON from ChatGPT or other AI assistants?

Yes. It removes the code fence and the text before and after the JSON, and fixes the usual mistakes: comments, trailing commas, single quotes and output that stopped at the token limit. A truncated answer is closed, but the data that was never generated cannot be recovered.

What if the repair is wrong?

It is a best guess at what the author meant. Compare the result with the original, and treat a low confidence score as a reason to check the data by hand before you use it.

Is my data uploaded?

No. The repair runs in your browser, so logs, API responses and AI output stay on your device.

Does it change number values?

No. Numbers keep their digits, so a long ID like 12345678901234567890 is not rounded. Only the notation is tidied: +1 becomes 1, .5 becomes 0.5 and hex such as 0x1F becomes 31.