JSON Repair — Fix Broken JSON and LLM Output
Paste broken JSON or a whole chatbot answer. Handles Markdown fences, cut-off output, stray quotes, missing commas, Python literals, comments and more.
Broken JSON
Repaired JSON
Fixes applied
Paste broken JSON or a whole chatbot answer. Handles Markdown fences, cut-off output, stray quotes, missing commas, Python literals, comments and more.
Broken JSON
Repaired JSON
Fixes applied
In short: paste broken JSON — or the entire reply from ChatGPT, Claude, Gemini or a local model — and get valid JSON back, with a list of every fix. It is a tolerant parser rather than a set of regexes, so it repairs the structure without ever rewriting the contents of your strings.
Language models write JSON one token at a time and are trained on JavaScript, Python and Markdown as much as on JSON. The result is output that is almost right: wrapped in a ```json fence with a friendly sentence before it, using True or single quotes, quoting a phrase inside a string without escaping it, or stopping mid-object when the response hits its token limit. One such slip makes JSON.parse throw for the whole response.
Text before and after the JSON and Markdown fences are removed; the first JSON object or array is kept.
Here is the data:
```json
{"id": 7}
```
Hope this helps! → {"id": 7} Unfinished strings, arrays and objects are closed; a key with no value is dropped instead of invented.
{"items": [{"id": 1}, {"id": 2, "name": "Wid → {"items": [{"id": 1}, {"id": 2, "name": "Wid"}]} Unescaped double quotes and raw line breaks inside a value are escaped; curly quotes become straight quotes.
{"bio": "Says "hello" a lot"} → {"bio": "Says \"hello\" a lot"} Single-quoted strings, bare keys, trailing or missing commas, True/False/None, NaN, Infinity, undefined and comments are converted to standard JSON.
{name: 'Ann', active: True, score: NaN,} → {"name": "Ann", "active": true, "score": null} Repair is a safety net, not a contract. In production, ask the model for structured output against a JSON Schema (OpenAI, Anthropic and Gemini all support it), then check the result. Generate that schema from a sample with JSON to JSON Schema, test responses with the JSON Schema Validator, and turn it into typed models with JSON to Pydantic or JSON to Zod.
Paste the whole answer — explanation, Markdown code fence and all. The tool pulls out the JSON, repairs it and lists every change it made, so you can see exactly what the model got wrong.
When a response hits the token limit mid-object, the repair closes the unfinished string, array and object so you get valid JSON with everything that was generated. A key whose value never arrived is dropped rather than guessed.
Yes. A double quote only ends a string when it is followed by JSON structure (a comma, colon, bracket or line break); otherwise it is treated as part of the text and escaped. Curly “smart” quotes are converted to straight ones.
Yes. Python’s True, False and None become true, false and null; single-quoted strings and bare keys are converted to double-quoted JSON; NaN, Infinity and undefined become null; trailing and missing commas are fixed.
No. The repair is a real parser, not a search-and-replace: //, /* */ and # comments are only removed outside strings, so a value like "https://example.com" is left intact.
No. The repair runs entirely in your browser with deterministic code — no upload and no model call. For agents and scripts, the same repair is available offline through the RealJSON MCP server.
After repairing, confirm the result with the JSON Validator, pretty-print it with the JSON Formatter, or check model-generated training data with the Fine-Tuning JSONL Validator.
Browse all free JSON tools →