Repair-JSON-stream – Fix broken JSON from LLM streaming (1.7x faster)
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 cardActual performance
Launch Intel predictions
Analyze your own launch →Incorrect prediction on native model
Similar products
JSON-Healer: Repair and Validate Broken JSON from LLM Outputs
LLM-JSON-guard – Middleware to auto-repair broken AI outputs
Repair JSON
Go, JSON, Streaming and Generics
ffjson: faster json serialization in Go
stream.json - The geek's home media streaming server
Fix your broken code faster.
Athelas – Automagically Repair Broken Code
Simple JSON Tool with Repair & AI Fix!
jsonpipe - stream JSON tweaks toolkit in GO