Rescue malformed LLM JSON — truncated, trailing commas, fences.
{
"user": "Ada",
"age": 36,
"tags": [
"math",
"pioneer"
]
}Handles the classic LLM failure modes: markdown fences, trailing commas, single quotes, bare keys, smart quotes, and truncated output from token limits. Deeply malformed input fails loudly with the parser position instead of guessing.
Models emit markdown fences around JSON, forget closing brackets when hitting token limits, or lapse into Python habits (single quotes, trailing commas). Each failure mode has a deterministic fix — this tool applies them in order and logs every change.
Fence stripping, outer-text trimming, smart quotes, bare keys, single-quoted strings, trailing commas, undefined/NaN/Infinity literals, and truncation closure via a string-aware bracket stack.
If the payload still fails to parse after all repairs, you get the parser error with position instead of a fabricated guess. Silent wrong answers are worse than loud failures — especially for data pipelines.
After repairing, validate the shape: pipe the output through JSON Diff against an expected example, or generate a Zod schema from a known-good sample using our JSON to Zod converter.
More tools you might find useful
Paste JSON, get a typed Zod schema — AI output validation ready.
Rank every major model by your real monthly API bill.
Per-request and monthly API costs across 17 models, side by side.
Pull every ``` code block out of Markdown or AI answers.