All tools. One workspace.
Command K
← Back to blog

How to Repair Broken JSON in Seconds

Unquoted keys, trailing commas, and single quotes break JSON parsers. Here is how to fix malformed JSON fast, why LLM output is the most common source, and how to validate the result.

Why JSON breaks in the first place

JSON is strict by design: strings need double quotes, keys cannot be unquoted, and trailing commas are forbidden. That strictness is what makes it a reliable data interchange format, but it also means small human or model mistakes produce invalid payloads that crash downstream parsers.

The most common sources of broken JSON today are LLM tool calls and code-generation prompts. A model that wraps keys in single quotes or leaves a trailing comma after the last field will pass a casual eyeball check and fail a strict parse.

The four most common JSON errors

1. Unquoted keys — `{ name: "Ada" }` should be `{ "name": "Ada" }`.

2. Single-quoted strings — JSON only allows double quotes.

3. Trailing commas — `{ "a": 1, }` is invalid; the comma after `1` must go.

4. Comments — JSON has no comments. A `// note` or `/* block */` will reject the whole document unless you strip them first.

A safe repair workflow

Run the broken text through a repair pass that normalizes quotes, removes trailing commas, and strips comments — then re-validate the output with a strict parser before you trust it. Repair-then-validate is safer than lenient parsing because it surfaces what actually changed.

Toolars JSON Repair runs entirely in your browser. Nothing is uploaded, so it is safe to use on payloads that contain sensitive values.

Tools mentioned in this article

Frequently asked questions

Is JSON repair safe for sensitive data?
Yes. The Toolars JSON Repair tool runs locally in your browser, so your text never leaves your device. No upload, no account, no logging.
Can repair fix JSON produced by an LLM?
In most cases yes. LLM output typically breaks JSON with single quotes, unquoted keys, or trailing commas — all of which a repair pass normalizes. Always re-validate the result with a strict parser afterward.
What is the difference between repair and lenient parsing?
Repair transforms the text into valid JSON so you can inspect what changed. Lenient parsing silently accepts malformed input, which can hide data corruption.