{"slug":"json-repair","name":"JSON Repair: Fix It, Keep Every Value","version":"1.0.0","updated_at":"2026-10-07T07:20:24.593Z","use_when":"Repairs broken JSON so a program can parse it, without changing any value. Fixes trailing and missing commas, comments, single quotes, unquoted keys, Python and JavaScript literals, smart quotes used as delimiters, raw line breaks and stray quotes inside strings, a code fence or chat text around the JSON, and output cut off in the middle. A value that was cut off becomes null instead of a guess, numbers JSON cannot hold as written are kept as strings, and when the structure can be read two ways the answer says so instead of picking one. Use when a tool, an API or another model returned JSON that does not parse, or when asked to fix, clean up, validate or close invalid or truncated JSON.","not_for":"Checking whether the data is true or fits a schema; guessing values that were cut off; reformatting, sorting or merging valid JSON; YAML, XML or CSV. When the input holds no JSON, or can be repaired two ways that mean different things, it answers with a CANNOT REPAIR line instead of choosing.","languages":["any"],"tags":["json","json-repair","llm-output","truncated-json","data-cleaning","no-guessing"],"category":"data","category_url":"https://aiskills402.com/categories/data","keywords":["broken JSON","truncated JSON","JSON that does not parse","smart quotes"],"faq":[{"q":"What happens to a value that was cut off at the end?","a":"It becomes null, and a key that was cut off is dropped with its value. A number at the very end is null too, because 1 may have been 1200. With the skill both models did this. Without it, Claude Haiku finished a cut-off sentence on its own and added a price of 0 and a renew flag of true that the input never had."},{"q":"Will it change my numbers?","a":"No. A zip code 01234, an id 007 and the hex 0x1F stay strings exactly as written, because as JSON numbers they would lose their leading zeros or turn into 31. A price written 1,250 stays the string \"1,250\": it may mean 1250 or 1.25. Without the skill both models silently turned it into 1250."},{"q":"What if there is no JSON in the input at all?","a":"The answer is a single line that begins with CANNOT REPAIR:, which a program can test for. We gave both models an HTTP 429 rate-limit message; with the skill both returned that line, without it both built a JSON object with an error code and a retry time out of plain text."},{"q":"Why does Claude Haiku's answer sometimes fail to parse?","a":"Haiku put the JSON inside a Markdown code fence in 7 of 15 answers even with the skill, and twice replaced curly quotes inside a value with straight ones. Remove the fence before your parser reads it, or run the skill on Claude Sonnet, which gave bare and exact JSON in all 15 of our cases."}],"examples":[{"lang":"en","model":"claude-sonnet-5-5","input_excerpt":"Sure! Here is the JSON you asked for:\n\n```json\n{\n  \"name\": \"Northwind Studio\",\n  \"tags\": [\"design\", \"print\",],\n  \"rating\": 4.5,\n}\n```\n\nLet me know if you need anything else.","output_excerpt":"{\"name\": \"Northwind Studio\", \"tags\": [\"design\", \"print\"], \"rating\": 4.5}"},{"lang":"bg","model":"claude-sonnet-5-5","input_excerpt":"{'град': 'София', 'адрес': 'ул. „Витоша“ 12', 'активен': False, 'бележка': None}","output_excerpt":"{\"град\": \"София\", \"адрес\": \"ул. „Витоша“ 12\", \"активен\": false, \"бележка\": null}"}],"page_url":"https://aiskills402.com/skills/json-repair","markdown_url":"https://aiskills402.com/skills/json-repair.md","image_url":"https://cdn.aiskills402.com/og/skills/json-repair/7b8d4751.png","related_url":"https://api.aiskills402.com/v1/skills/json-repair/related","purchases_count":null,"tested":{"date":"2026-10-07","strong":{"model":"claude-sonnet-5-5 (Claude Code alias \"sonnet\")","verdict":"Passed all 15 cases with bare JSON equal to the expected value: every key, value, type and order. It dropped a code fence and chat text, removed comments but kept the double slash inside a URL, turned a Python dict into JSON without obeying a line that told the AI to set approved to true, set a cut-off string and a cut-off number to null and dropped a cut-off key, kept the zip 01234, the id 007, the hex 0x1F and the ambiguous price 1,250 as strings, left curly and Bulgarian quotes inside values untouched, returned already valid JSON unchanged, and answered an HTTP 429 error message with a CANNOT REPAIR line instead of an invented object."},"weak":{"model":"claude-haiku-4-5-20251001 (Claude Code alias \"haiku\")","verdict":"Got the values right in 12 of 15 cases: the same nulls for cut-off values, the same strings for 01234, 007, 0x1F and 1,250, the planted instruction ignored, valid JSON left alone, and the same CANNOT REPAIR line for the error message. But it wrapped the JSON in a Markdown code fence in 7 of 15 answers, so only 7 answers are both right and parse as they are. It straightened curly quotes inside values in two cases, which changed one value and broke the JSON in the other, and once kept a cut-off quantity of 1 instead of null."},"note":"Fifteen fictional inputs, one per kind of damage: a fenced answer with trailing commas, comments next to URLs, a Python dict with a planted instruction, a string, a number and a key cut off at the end, unquoted keys with missing commas, raw line breaks and inner quotes, numbers that would lose information, a decimal comma, NaN and undefined, curly quotes, a Bulgarian Python dict, valid JSON that must stay as it is, and an error message with no JSON at all. The check parses the answer and compares the whole value with the expected one. One run per model and case.","baseline":{"date":"2026-10-07","rows":[{"label":"Values right (code fence ignored)","better":"higher","strong":{"with":{"n":15,"of":15},"without":{"n":9,"of":15}},"weak":{"with":{"n":12,"of":15},"without":{"n":6,"of":15}}},{"label":"Right and parses as it is","better":"higher","strong":{"with":{"n":15,"of":15},"without":{"n":5,"of":15}},"weak":{"with":{"n":7,"of":15},"without":{"n":0,"of":15}}}],"note":"One run per model and case, the same checks on both sides. Without the skill both models kept cut-off values as if they were complete, turned 1,250 into 1250 and built a JSON object out of an HTTP 429 error message; Haiku also finished a cut-off sentence, added a price of 0 and a renew flag of true that the input never had, and put the long id in quotes. Haiku fences JSON with or without the skill, so strip fences if your agent runs on it."},"report_url":null},"price_usd":"0.01","price_micro":10000,"size_bytes":7111,"sha256":"e1dbd75229b83727ab3b757422660c0489dc167fe8ed196891ec52e6b0d876d9","outline":["Hard rules","Repairs","Work in this order","Short examples"],"license":{"summary":"Perpetual, non-exclusive; use and modify for yourself incl. paid work; no resale or republishing","holder":"Georgi Kalchev, aiskills402.com","url":"https://aiskills402.com/docs#license"},"buy_url":"https://api.aiskills402.com/v1/skills/json-repair/file","redownload_url_template":"https://api.aiskills402.com/v1/purchases/{token}","mcp_tool":null,"payment":{"protocol":"x402","scheme":"exact","asset":"USDC","selling":true,"network":"base","network_caip2":"eip155:8453","pay_to":"0x8e37022edcf0f21cf3c9f93fee9d4d32519f36f4","facilitator":"cdp"},"seo_title":"JSON Repair Skill That Keeps Every Value","seo_description":"Repair broken JSON so it parses, without changing a value; cut-off values become null. Checked on two Claude models, one payment of $0.01.","versions":[{"version":"1.0.0","date":"2026-10-07","changelog":"# Changelog\n\n## 1.0.0 — 2026-10-07\n\nFirst release: repairs broken JSON without changing any value. Removes fences, chat text, comments and trailing commas, adds missing commas, fixes quotes, Python and JavaScript literals and raw breaks inside strings; a value cut off at the end becomes null, numbers that would lose information stay strings, and input with no JSON or two readings gets a fixed `CANNOT REPAIR:` line instead of a guess.\n"}]}