LLM JSON Repair
Paste broken JSON from any LLM. The repair pass strips fences, comments, smart quotes, trailing commas, and Python literals — then re-parses to confirm it's valid.
About LLM JSON Repair
LLMs frequently emit JSON that is almost valid but fails JSON.parse — wrapped in markdown fences, sprinkled with comments, using Python literals, or missing quotes on keys. This tool runs a deterministic repair pipeline and re-validates the result, showing exactly which fixes were applied and how many times.
What this tool does
10-step repair pipeline
Fences → BOM → smart quotes → comments → Python literals → single quotes → unquoted keys → trailing commas → control chars. Applied in order, each step is idempotent.
Fix report
Every repair is counted and labelled so you can see what the model got wrong — useful for prompt engineering and debugging structured-output prompts.
Re-validation
After repair the output is passed through JSON.parse. If it still fails, the parser error is shown so you know exactly where the remaining problem is.
Pretty-printed output
Valid output is re-serialized with 2-space indentation for readability before display.
Pipeline
- JSON Formatter — format and validate the repaired output.
- JSON to TypeScript — generate typed interfaces from the repaired structure.
- JSON ↔ YAML — convert repaired JSON to YAML config.
- MCP Config Validator — repair a pasted MCP config then validate it.
Frequently asked
- Why do LLMs produce broken JSON?
- Language models generate text token by token without a strict grammar constraint. They frequently wrap output in markdown code fences, add JavaScript-style comments to explain fields, use single quotes instead of double quotes, leave trailing commas, or emit Python literals like True/False/None. None of these are valid JSON, but they are common in training data.
- What repairs does this tool apply?
- In order: strip markdown code fences (```json ... ```), remove JSONP wrappers, strip UTF-8 BOM, normalize smart/curly quotes to straight quotes, remove // line comments and /* */ block comments, replace Python True/False/None with true/false/null, convert single-quoted strings to double-quoted, quote unquoted object keys, remove trailing commas before } or ], and escape literal newlines/tabs inside strings.
- Does it handle deeply nested or large JSON?
- Yes — the repair pass is a single linear scan over the text, so it scales to large payloads without performance issues. The only limit is your browser's memory. For very large outputs (>10 MB) consider splitting the payload first.
- What if the JSON is still invalid after repair?
- The tool reports the JSON.parse error message so you can see exactly where the remaining problem is. Common unrecoverable cases: truncated output (the model hit a token limit mid-object), deeply nested unclosed brackets, or binary data embedded in a string. In those cases you'll need to manually fix the remaining issue.
- Is my data sent anywhere?
- No. All repair logic runs in your browser. Your model output never leaves your device.
Related Tools
LLM Cost Calculator
Calculate the cost of OpenAI, Anthropic, Google, Meta, and Mistral models per million tokens.
LLM Token Counter
Approximate token counts for ChatGPT, Claude, Gemini, and Llama. Counts characters, words, and tokens per family.
Prompt Template Tester
Test prompt templates with variables, conditionals, and loops. Mustache-flavored syntax for LLM workflows.
MCP Config Validator
Validate Model Context Protocol server configs for Claude Desktop, Cursor, and other MCP clients.
JSON Formatter / Validator
Format, validate, and beautify JSON with syntax highlighting.
JSON ↔ YAML Converter
Convert between JSON and YAML formats bidirectionally.