This article is rendered from the draft in the repo. The benchmark scripts, corpus generator and raw per-case results live in benchmark/ (seed 20261129) — re-run them and check the numbers.

I Benchmarked My Own JSON-Repair Library Against json_repair. It Lost. Here's the Data.

TL;DR: I wrote llmparse, a zero-dependency Python library that extracts and repairs JSON from raw LLM output. I benchmarked it against json_repair (5,143 stars, ~49M downloads/month), partialjson, and pure-json on 194 hand-built damaged cases. Round 1: json_repair won clearly — 77% exact vs llmparse's 57%. Round 2, after I fixed the gaps the benchmark found (comments, curly quotes, missing commas, truncation recovery) and stopped the extractor from silently returning nested fragments: llmparse parses 100% and gets 78% exactly right — a hair ahead of json_repair's 77%. The remaining 0% rows (unescaped quotes/newlines, truncation exact, NaN/Infinity) are structural: the data is gone, or the repair is a judgment call both libraries make the same way. This post is the receipt, and the roadmap it implies.


Why benchmark your own library against the biggest one?

LLMs promise JSON and deliver markdown fences, apologies, single quotes, trailing commas, Python literals — and, when the token budget runs out, JSON that stops mid-string. I built llmparse for this: zero dependencies, Python 3.9+, a small set of explicit repair rules, and a guarantee it never touches anything inside string values.

The obvious question is: why not just use json_repair? It's the dominant library in this space, it's battle-tested, and it's what most people already reach for. I wanted a real answer instead of a README claim, so I ran the comparison. If my library lost, I wanted to know exactly where, by how much, and why — because that's a roadmap, not an embarrassment.

The contenders

Library Version What it is
llmparse 0.1.2 on PyPI (benchmarked here — the round-2 fixes shipped in 0.1.2) Zero-dependency extraction + repair of JSON in raw LLM output. Ten explicit repair rules.
json_repair 0.64.9 The dominant JSON repair library. Full parser, schema repair, streaming, CLI.
partialjson 1.2.0 A parser for partial (streaming, truncated) JSON. Tested with its default create_json_parser().
pure-json 0.1.1 Extracts and heals the first JSON block from messy text (extract(..., strict=False)).

One fairness note up front: partialjson is not a general repair library. It's a streaming parser for incomplete JSON, so it was never going to handle single quotes or markdown fences. Its low overall score reflects scope, not quality — and on its home turf (truncation) it parses 100% of cases. I'm including it because people do reach for it in LLM pipelines, but read its row with that context.

Method: a synthetic corpus, fully disclosed

This is a synthetic benchmark, and I want to be explicit about what that means: these are not real LLM outputs. I wrote 14 base JSON documents by hand (nested objects, arrays of objects, Unicode/emoji strings, escaped strings, floats and exponents, deeply nested structures, URLs and timestamps, strings containing braces), then applied 13 damage transforms with a deterministic generator (fixed seed 20261129), producing 194 cases. The transforms:

Each case stores the original document, so scoring is exact. Every library was called the way its own README documents, end to end: feed the raw damaged text, expect a parsed Python object back. No preprocessing, no retries, no library-specific tuning. Each case ran 3 times; timing is the median. The whole run is deterministic — I ran it twice and got identical success/exact numbers.

Three metrics:

Limitations — read these before the numbers

Results

Overall (n = 194)

Library Success Exact Prefix Median time
json_repair 100% (194) 77.3% (150) 79.4% 0.18 ms
llmparse 100% (194) 78.4% (152) 80.9% 0.28 ms
pure-json 60.3% (117) 56.2% (109) 56.2% 0.08 ms
partialjson 41.2% (80) 22.2% (43) 22.2% 0.05 ms

json_repair and llmparse now both return something on every case — but note the gap between 100% success and ~78% exact: a fifth of the time each returns a plausible-looking wrong answer. More on that below.

Speed is a non-story at this scale: everything is sub-millisecond per case. llmparse is ~1.5× slower than json_repair on median (0.28 ms vs 0.18 ms), which matters only if you're parsing millions of documents.

Exact-match rate by damage type

Damage n llmparse json_repair partialjson pure-json
markdown fence 14 100% 100% 0% 100%
prose around JSON 14 100% 100% 0% 100%
single quotes 13 100% 100% 0% 92%
unquoted keys 13 100% 100% 0% 100%
trailing commas 14 100% 100% 100% 100%
Python literals 14 100% 100% 7% 100%
duplicated output 14 100% 100% 100% 100%
combined (fence + prose + commas) 14 100% 100% 0% 100%
comments 14 100% 100% 0% 0%
curly quotes 14 100% 86% 0% 0%
missing comma 14 100% 100% 100% 0%
unescaped quote/newline in string 14 0% 0% 0% 0%
truncation 14 0% 0% 0% 0%
NaN / Infinity / undefined 14 0% 0% 0% 0%

(Truncation exact is 0% for everyone by construction — the data is gone. The honest metric there is prefix: llmparse 36% vs json_repair 29%.)

Reading the results

Where llmparse is perfect. On eleven of the fourteen damage types — fences, prose, single quotes, unquoted keys, trailing commas, Python literals, duplicated output, the combined case, and now comments, curly quotes, and missing commas — llmparse is 100% exact, tied with or ahead of json_repair. If your LLM output looks like the usual mess, both libraries give you the right answer every time.

Where llmparse now leads. Curly quotes: llmparse is 100% exact, json_repair 86%. json_repair's two misses are both strings containing a comma — it cuts the value at the comma ("Zürich — 10°C, 50% humidity" becomes "Zürich — 10°C"). llmparse keeps the whole string because its curly-quote rule is string-aware. Truncation prefix: llmparse 36% vs json_repair 29% — see the round-2 notes below for how.

Where exact is 0% for everyone — and that's structural, not a bug. Three rows:

"Success" flatters everyone, including my library. This is the part of the benchmark I found most instructive. A few examples of what "success" actually returned:

One round-1 problem is gone: llmparse used to silently return a nested fragment when the top-level object failed (a # comment case returned ['math', 'poetry', 'engines'] — the tags array). The extractor now returns only the top-level value or nothing, and parse() raises instead of handing you a fragment. If you use llmparse, check what you got, not just that you got something.

Two small behavioral notes. partialjson prints a Parsed JSON with extra tokens diagnostic to stdout on every case with trailing content — noisy if you run it in a pipeline. And partialjson is not thread-safe in my harness: running libraries concurrently made its results move between runs; single-threaded, it's fully deterministic. (That's a benchmark-harness note, not a library verdict — but if you parallelize partialjson calls, verify your own setup.)

Round 2: what changed

The benchmark did its job: it turned a vague "is my library any good?" into a punch list, and round 2 closed it. Same corpus, same seed (20261129), same script — the only change is the library.

  1. Curly-quote rule. Straightforward normalization, zero ambiguity — and it beats json_repair (100% vs 86%) because it never touches anything inside string values, including the comma that trips json_repair.
  2. # comments and missing commas. Both are common in real LLM output and both were 0% — now 100%. The missing-comma rule only fires where valid JSON could never have two values side by side, and it deliberately does not guess a comma after a bare word: a time split by a stray quote ("2026-11-29"T06:30:00Z) looks exactly like a key, and guessing there corrupts the string repair.
  3. Truncation recovery. Prefix 7% → 36% (success 71% → 100%). Two changes: a member cut off mid-key is dropped instead of failing the whole parse ({"a": 1, "smal → {"a": 1}), and a number cut off mid-token is trimmed back to a complete number (3. → 3, 6.02e → 6.02). Partial string values are still kept — the value is data, not garbage — which is why prefix isn't higher.
  4. The extractor fallback. Silently returning a nested fragment is worse than failing: it looks like success. extract() now returns only the top-level value or None, and parse() raises LLMParseError instead of handing you a fragment.
  5. Unescaped quotes/newlines. Success 43% → 100%, exact still 0% — for the principled reason above. The repair escapes a stray quote when the next significant character shows the string doesn't end there, and escapes raw newlines instead of removing them (a real multiline string means the break).

The honest summary after round 2: llmparse is a zero-dependency alternative that is exactly right on the common cases, ahead of json_repair on this corpus by two cases, with no dependency to audit or break — and the remaining gaps are documented above, not hidden. The benchmark lives in the repo (benchmark/, seed 20261129), so anyone can re-run it and check.

Reproduce it


llmparse is on GitHub and PyPI (pip install llmparse-py). There's a live playground that runs the real library in your browser via Pyodide — paste broken JSON and watch it get repaired. The playground runs the latest PyPI release (0.1.2), which includes the round-2 fixes in this post. If you try the benchmark on your own data and get different results, I'd genuinely like to hear about it — that's how this gets better.