"category": "utility",

JSON Repair - Fix Broken JSON Automatically

"tldr": Paste broken JSON and get valid JSON back - unquoted keys, single quotes, trailing or missing commas, comments, Python literals, and truncated output fixed automatically, in your browser.

Paste JSON that will not parse and get a valid, formatted document back. The repair understands JSON structure, so it fixes the mistakes people and programs actually make - JavaScript-style unquoted keys and single quotes, trailing commas, missing commas between properties, // and /* */ comments, Python True/False/None, and output that was cut off mid-document - without touching commas, colons, or quotes inside your string values.

{"broken json": "valid json"}

Use it when you need the data now: a config copied from JavaScript, a log line, an LLM response that broke off, or an API payload someone edited by hand. When you would rather understand the error than have it fixed for you, paste the same input into the JSON formatter or look the message up in our JSON error guides.

How to repair broken JSON

  1. 1Paste the invalid JSON into the input panel.
  2. 2The repaired document appears on the right, formatted with 2-space indentation.
  3. 3Check the output: a repair is a best guess, so confirm values ended up where you expect.
  4. 4Copy or download the valid JSON.

Convert Broken JSON to Valid JSON in code

JavaScript (jsonrepair)
import { jsonrepair } from "jsonrepair";

const broken = "{name: 'Ada', tags: ['x',], active: True}";
const data = JSON.parse(jsonrepair(broken));
// { name: "Ada", tags: ["x"], active: true }
Python (json-repair)
# pip install json-repair
import json
from json_repair import repair_json

broken = "{name: 'Ada', tags: ['x',], active: True}"
data = json.loads(repair_json(broken))

Frequently asked questions

What kinds of errors can it fix?

Unquoted property names, single-quoted or smart-quoted strings, trailing commas, missing commas between properties or array items, // and /* */ comments, Python constants (True, False, None), undefined, unclosed brackets and strings from truncated output, Markdown code fences around the JSON (common in LLM replies), and JSONP wrappers like callback({...}).

What can it not fix?

Input that is not JSON-like at all, such as an HTML error page, and mistakes that are valid syntax but wrong data: a misspelled key, a value in the wrong place, or a number stored as a string. Bare words that are not JSON constants are turned into strings (NaN becomes "NaN"), so review the output before relying on it.

Is my JSON uploaded anywhere?

No. The repair runs entirely in your browser; nothing you paste is sent to a server. That makes it safe for configs and payloads that contain credentials or personal data.

Should I repair JSON or fix the source?

Repair is right for one-off data: a file you were sent, a pasted log, a truncated LLM response. If a program you control keeps producing broken JSON, fix the producer instead - build output with a real serializer (JSON.stringify, json.dumps) rather than string concatenation, so the problem cannot recur.

How do I repair JSON in code?

In JavaScript and TypeScript, the jsonrepair npm package (the library this page uses) exposes jsonrepair(text), which returns a valid JSON string. In Python, the json-repair package on PyPI provides repair_json(text). Both are worth wrapping around LLM output before you parse it.

Last updated:

You might also need

Free and in-browser, like everything on JSON Console. Browse all tools →