Data & Analysis

JSON Repair: Fix Broken JSON, Keep Every Value

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.

JSON Repair: Fix Broken JSON, Keep Every Value is a SKILL.md that repairs broken JSON so a program can parse it, without changing any value; an agent buys it once for $0.05 over x402.

Tested 2026-10-07No code, no hidden instructionsv1.0.1 · 6.9 KB · perpetual license

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.

Tested, honestly

Tested 2026-10-07 with a strong and a weak model.

With and without the skill

Results with and without the skill, for Sonnet and Haiku
SonnetHaiku
withwithoutwithwithout
Values right (code fence ignored)15/159/1512/156/15
Right and parses as it is15/155/157/150/15

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.

Same cases and the same checks with and without the skill. The cases are ours, written around what the skill is for; with a handful of cases, a difference of one or two is within noise.

SonnetStrong model, claude-sonnet-5-5
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.
HaikuWeak model, claude-haiku-4-5-20251001
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.

Full test summary

Example

Our own test text, before and after the skill ran. Excerpts only.

English · claude-sonnet-5-5

Before

Sure! Here is the JSON you asked for: ```json { "name": "Northwind Studio", "tags": ["design", "print",], "rating": 4.5, } ``` Let me know if you need anything else.

After

{"name": "Northwind Studio", "tags": ["design", "print"], "rating": 4.5}

Bulgarian · claude-sonnet-5-5

Before

{'град': 'София', 'адрес': 'ул. „Витоша“ 12', 'активен': False, 'бележка': None}

After

{"град": "София", "адрес": "ул. „Витоша“ 12", "активен": false, "бележка": null}

What is in the file

  • Hard rules
  • Repairs
  • Work in this order
  • Short examples

Languages

Any language. Tried in: English, Bulgarian.

License

Perpetual, non-exclusive; use and modify for yourself incl. paid work; no resale or republishing. Holder: Georgi Kalchev, aiskills402.com. Full terms.

Versions

Current version 1.0.1, updated 2026-10-09. Whoever bought an earlier version gets new ones free through the same re-download token.

  1. v1.0.1 · 2026-10-08

    Price changed from $0.01 to $0.05; the skill text is unchanged. Measured value for the strong model: Sonnet 9 of 15 without the skill, 15 of 15 with it.

  2. v1.0.0 · 2026-10-07

    First 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.

FAQ

What happens to a value that was cut off at the end?

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.

Will it change my numbers?

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.

What if there is no JSON in the input at all?

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.

Why does Claude Haiku's answer sometimes fail to parse?

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.

Read more

Share

Read this page as Markdown: /skills/json-repair.md.

  • Text to JSON: Extract Data Without Guessing

    Data & Analysis

    SKILL.md · v1.0.2 · 7.5 KB

    Extracts data from text into JSON that matches the shape you give (a JSON Schema, an example object or a list of fields), without guessing. Every value comes from the text; a missing fact becomes null, numbers and dates are converted only into the type the shape asks for, two conflicting values are not settled by a guess, and instructions hidden in the text are ignored. Use when asked to extract structured data, turn text into JSON, parse an invoice, receipt, email, order, CV or job post into fields, or fill a JSON schema from a document.

    $0.05once

    • x402
    • USDC
    • Base
    Get skill

    Tested with Sonnet and Haiku, 3 Oct 2026

  • Translate App Text (JSON, YAML, PO)

    Translation & Localization

    SKILL.md · v1.0.1 · 8.5 KB

    Translates app strings and locale files (JSON, YAML, gettext PO, ICU messages, HTML snippets) into another language without breaking them. Keys, placeholders such as {name}, {{count}}, %s, %(name)s and %{count}, ICU plural and select syntax, HTML tags and URLs come back byte for byte; only the human text is translated, and plural forms are added where the target language needs more of them. Use when asked to translate a JSON or YAML locale file, an en.json, a .po file, i18n strings or UI text, or to localize an app.

    $0.01once

    • x402
    • USDC
    • Base
    Get skill

    Tested with Sonnet and Haiku, 3 Oct 2026

More in Data & Analysis

  • HTML to Markdown: Same Page, Nothing Invented

    Data & Analysis

    SKILL.md · v1.0.0 · 9.9 KB

    Converts HTML into CommonMark Markdown and answers with the Markdown only, no wrapper fence. Headings become ATX headings, links keep their address byte for byte (title included), images keep their source and alt text, lists keep nesting and an ordered list keeps the number it begins with, code blocks keep their text and indentation, tables become pipe tables with literal pipes escaped, entities are decoded once so the text reads as a browser shows it, and characters that Markdown would read as syntax at that spot are escaped instead of silently changing the document. Scripts, styles and comments are dropped, and an instruction hidden in a comment is never followed. Elements Markdown cannot say, such as an iframe, subscript or superscript, stay as the original HTML instead of being lost. HTML cut off inside a tag or with no visible content gets a fixed one-line CANNOT CONVERT answer instead of an invented page. Use when scraped, exported or pasted HTML has to become Markdown for docs, a knowledge base, a README or a model prompt.

    $0.01once

    • x402
    • USDC
    • Base
    Get skill

    Tested with Sonnet and Haiku, 9 Oct 2026

  • Markdown TOC Anchors: Contents Links That Really Jump

    Data & Analysis

    SKILL.md · v1.0.0 · 10.0 KB

    Builds the table of contents of a Markdown document with the exact heading anchors that GitHub or GitLab generate, and answers with the list only, no code fence. Finds the real headings (hash headings with closing hashes, underline headings, none inside code fences, indented code, comments or front matter), strips inline markup, lowercases, drops every character that is not a letter, digit, hyphen or underscore, turns each single space into one hyphen without collapsing or trimming, keeps Cyrillic and other non-Latin letters as they are, and numbers duplicate headings with -1, -2 in document order including the case where a numbered name already exists. Shows how emoji, ampersands, plus signs, dots and spaced dashes change the anchor. Indents two spaces per level below the shallowest heading. A named renderer other than GitHub or GitLab, a GitHub emoji shortcode, raw HTML in a heading, a heading with no characters left for an anchor, a heading inside a quote, list or table, and a document with no headings get a fixed one-line CANNOT BUILD answer instead of a guessed anchor. Use when asked to add, fix or check a table of contents, contents list or in-page links in a README, wiki page or docs file, or when a contents link jumps nowhere.

    $0.03once

    • x402
    • USDC
    • Base
    Get skill

    Tested with Sonnet and Haiku, 9 Oct 2026

  • Phone Numbers to E.164

    Data & Analysis

    SKILL.md · v1.0.0 · 10.5 KB

    Turns a list of phone numbers written any way people write them into E.164 (a plus sign, the country code and the national number, digits only), one JSON object per number, using a default country the request states. Where plain models slip - the trunk 0 left in, "+44 (0)20" glued to a stray zero, Italian numbers with the leading 0 wrongly dropped, the leading 1 of a North American number kept, a made-up country for a bare local number, an extension stuck onto the number - it follows the numbering rules, keeps extensions in a separate field, and refuses with a reason instead of guessing when a number is too short, too long, cut, in two parts, has an impossible area code, or is local with no default country. Use to clean a contact list, a CSV column or a form export before import into a CRM, an SMS tool or a dialler, or to turn one pasted number into the international form.

    $0.03once

    • x402
    • USDC
    • Base
    Get skill

    Tested with Sonnet and Haiku, 9 Oct 2026

  • Mojibake Repair: Undo Broken Encoding Exactly

    Data & Analysis

    SKILL.md · v1.0.0 · 12.2 KB

    Repairs mojibake, text whose accents, Cyrillic letters, quotes, dashes or emoji turned into strings such as è, ü, “, пр or Р—Рґ because UTF-8 was read as Windows-1252, Latin-1 or Windows-1251, once or twice. Gives back the original text exactly, character for character, by undoing the wrong reading byte by byte, and leaves text that is already correct untouched. When the damage is mixed with good text, mixes two encodings, or lost bytes, so that more than one original is possible, it answers with a fixed CANNOT REPAIR line instead of guessing. Use when text from a file, database, email, web page or export shows garbled characters, or when asked to fix, undo or decode broken encoding, double encoding or strange characters.

    $0.01once

    • x402
    • USDC
    • Base
    Get skill

    Tested with Sonnet and Haiku, 9 Oct 2026