Re

Repair-JSON-stream – Fix broken JSON from LLM streaming (1.7x faster)

Hacker News

Repair-JSON-stream – Fix broken JSON from LLM streaming (1.7x faster)

I've been building LLM-powered apps and kept hitting the same problem: when you stream JSON from OpenAI/Anthropic, it arrives incomplete mid-generation. {"message": "I'm currently generating your resp JSON.parse dies. You either wait for the full response (slow) or try to parse incrementally (hard). I wrote a single-pass state machine that repairs broken JSON as chunks arrive. Technical approach: - Zero external dependencies - everything from scratch - No regex (avoids ReDoS vulnerabilities) - O(n) single-pass processing - Stack-based context tracking - Character classification via bitmask lookup table - Works in Node.js, Deno, Bun, browsers, Cloudflare Workers What it handles: - Truncated strings and unclosed brackets - Python constants (None, True, False) - Single quotes, trailing commas, unquoted keys - JSONP wrappers, MongoDB types (NumberLong) - LLM "thinking" blocks and markdown fences - String concatenation ("a" + "b") The streaming benchmark shows 1.7x faster than jsonrepair - we avoid re-parsing the entire document on each chunk. 7KB minified. TypeScript-first with full type definitions. Curious what edge cases others have hit - always looking to improve coverage.

Share card

Actual performance

1points
2comments
Did not reach leaderboard

Launch Intel predictions

Analyze your own launch →
Product HuntOn track for Day 1 leaderboard · Strong signals: mac, apps, context · Missing: agents, macos, agent
70%70% predicted probability of success on Product Hunt, based on ML models trained on real launch data.
best fitHighest predicted score across all platforms for this description.
Indie HackersFits the IH revenue-focused audience · Missing: supports, reddit linkedin, podcasting
60%60% predicted probability of success on Indie Hackers, based on ML models trained on real launch data.
Hacker NewsStrong engagement from HN community · Strong signals: io · Missing: https docs, excited, just released
51%51% predicted probability of success on Hacker News, based on ML models trained on real launch data.
nativeThis product was originally launched on this platform.
TrustMRRLess likely to generate early MRR · Strong signals: apps, way · Missing: mobile apps, ios, personal
41%41% predicted probability of success on TrustMRR, based on ML models trained on real launch data.
AppSumoMay struggle as an AppSumo deal · Missing: plus, platform, intuitive
38%38% predicted probability of success on AppSumo, based on ML models trained on real launch data.
Acquire.comPre-revenue stage for this audience · Strong signals: arr · Missing: mrr, revenue, profit
14%14% predicted probability of success on Acquire.com, based on ML models trained on real launch data.
BetaListMay not resonate with beta-testers · Missing: web3, chat, crypto
1%1% predicted probability of success on BetaList, based on ML models trained on real launch data.

Incorrect prediction on native model

Similar products

JS
JSON-Healer: Repair and Validate Broken JSON from LLM Outputs28%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

JSON-Healer: Repair and Validate Broken JSON from LLM Outputs

Hacker News1
LL
LLM-JSON-guard – Middleware to auto-repair broken AI outputs34%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

LLM-JSON-guard – Middleware to auto-repair broken AI outputs

Hacker News1
Re
Repair JSON47%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Repair JSON

Hacker News7
Go
Go, JSON, Streaming and Generics39%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Go, JSON, Streaming and Generics

Hacker News3
ff
ffjson: faster json serialization in Go48%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

ffjson: faster json serialization in Go

Hacker News83
st
stream.json - The geek's home media streaming server43%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

stream.json - The geek's home media streaming server

Hacker News3
Crashdeck
Crashdeck52%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Fix your broken code faster.

Indie Hackers1analytics
At
Athelas – Automagically Repair Broken Code60%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Athelas – Automagically Repair Broken Code

Hacker News8
Simple Tools
Simple Tools11%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Simple JSON Tool with Repair & AI Fix!

Product Hunt+13
js
jsonpipe - stream JSON tweaks toolkit in GO49%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

jsonpipe - stream JSON tweaks toolkit in GO

Hacker News2