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.
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.
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.
| 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.
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:
```json)// and # commentsTrue/False/None)NaN / Infinity / undefined in place of a numberEach 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:
json_repair or llmparse may score differently. Python 3.12, Linux, single machine.| 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.
| 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%.)
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:
llmparse now returns a value 100% of the time (was 43%), same as json_repair — and returns the same values it does. But exact is 0% for both, and it should stay that way: the generator inserts a quote or newline where the original had none, so the only way to be "exact" would be to delete it. Deleting is guessing — a real model writing She said "hello" means the quotes as content, and a real multiline string means the line break. Both libraries preserve the stray character as content, which is the principled repair; exact is unwinnable here without destroying real content.llmparse 36% vs json_repair 29%.NaN/Infinity/undefined. The original number was destroyed — the input says Infinity where the document said 36, and nothing can recover 36. Every library returns inf and scores 0% exact. Don't read those rows as failures; read them as "this metric doesn't apply here.""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:
{"nam (truncated mid-key): json_repair returned ['nam'] — a list. partialjson returned {'nam': None} — it invented a value. Both counted as "success." llmparse now returns {} — the honest prefix (the member never arrived).llmparse's 100% success overstates it too: 42 of its 194 "successes" are wrong answers (14 truncation partials, 14 unescaped content-preserving values, 14 destroyed numbers). Same story for json_repair — 44 of its 194 are wrong. Exact match is the number that matters, and that's 78% vs 77%.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.)
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.
json_repair (100% vs 86%) because it never touches anything inside string values, including the comma that trips json_repair.# 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.{"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.extract() now returns only the top-level value or None, and parse() raises LLMParseError instead of handing you a fragment.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.
20261129, 194 cases. Generator and runner: benchmark/ in the llmparse repo.llmparse.parse(text); json_repair.repair_json(text, return_objects=True); partialjson.create_json_parser().parse(text); pure_json.extract(text, strict=False).benchmark/.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.