Truncated documents, unterminated strings, trailing commas, unclosed brackets, and markdown code fences wrapped around the JSON — the failure modes real LLMs produce.
Why not just re-prompt the model?
Because that costs another call and often truncates again. Repairing locally is instant and free. We wrote this after truncated JSON silently produced zero output for a full day in our own pipeline.
Is it safe?
It never executes anything — it only parses and rebalances structure. Nothing leaves your browser.