BACK_TO_FEEDAICRIER_2
ai-json-safe-parse repairs broken LLM JSON
OPEN_SOURCE ↗
REDDIT · REDDIT// 20d agoOPENSOURCE RELEASE

ai-json-safe-parse repairs broken LLM JSON

The package adds a small recovery pipeline for malformed JSON from local and hosted LLMs, handling code fences, trailing commas, comments, unquoted keys, single quotes, and prose around the payload. It ships three ergonomics-friendly APIs - result, nullable, and strict throw - and is dependency-free across Node, browsers, and edge runtimes.

// ANALYSIS

This is the right kind of boring utility: narrow, cheap, and likely to save more time than it takes to add. It doesn’t try to replace schema validation; it just gets you from messy model text to something parseable fast.

  • The recovery order matters: direct parse first, then extraction and normalization, then increasingly aggressive fixups, which keeps the happy path predictable.
  • The API trio covers most call sites without forcing one error-handling style on every project.
  • Zero dependencies and browser/edge support make it easy to drop into both backend agents and frontend AI flows.
  • The package is especially useful for local models, which often need a last-mile cleanup layer before their output is safe to consume.
  • It’s a good fallback, but anything user-facing should still validate the parsed object against a schema.
// TAGS
llmdevtoolopen-sourceautomationai-json-safe-parse

DISCOVERED

20d ago

2026-03-22

PUBLISHED

20d ago

2026-03-22

RELEVANCE

8/ 10

AUTHOR

ardme