jsonrepair

Repair invalid or broken JSON documents — missing quotes, trailing commas, truncation, and more

Library
npm
v3.15.0
2,395stars
ISC

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
55/100Fair
Development Activity52
Maintenance28
Community40
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
79/100Good
Architecture75
Code Quality82
Innovation72
Learning Curve88

jsonrepair parses malformed JSON and rewrites it into valid JSON, fixing common problems like missing quotes around keys, trailing commas, unescaped characters, truncated documents, single-quote strings, JS-style comments, JSONP wrappers, and newline-delimited JSON. It is commonly used to salvage output from LLMs (which frequently emit near-valid JSON), scraped web data, and legacy configuration files that aren’t strictly spec-compliant.

The library ships as ESM, CommonJS, and UMD builds, includes a small CLI (jsonrepair), and provides a streaming API for handling documents too large to hold in memory. It has no runtime dependencies, keeping the installed footprint minimal for use in both Node.js and browser contexts.

What You Get

  • A jsonrepair() function that accepts a malformed JSON string and returns a repaired, valid JSON string
  • A streaming API (jsonrepairTransform) for repairing JSON incrementally without loading the whole document into memory
  • A CLI (jsonrepair command) for repairing JSON files from the shell or piping through stdin/stdout
  • ESM, CommonJS, and browser UMD builds with zero runtime dependencies
  • A broad, documented catalog of specific repair rules (missing commas/brackets, smart quotes, Python constants, MongoDB types, string concatenation, and more)

Common Use Cases

  • Cleaning up JSON emitted by LLMs, which often omit quotes, add trailing commas, or wrap output in markdown code fences
  • Recovering usable data from truncated JSON responses (e.g. a network request cut off mid-stream)
  • Parsing relaxed or legacy config files that use JS-style object literals instead of strict JSON
  • Ingesting scraped or hand-edited JSON/JSONP data that doesn’t validate against a strict parser

Under The Hood

Architecture: The core repair logic lives in src/streaming/core.ts, a hand-written character-by-character parser/rewriter that walks the input tracking a stack.ts-based nesting stack of objects/arrays, emitting corrected output as it goes rather than building an AST and re-serializing; src/regular/jsonrepair.ts wraps this core into a simple synchronous string-in/string-out function, while src/streaming/stream.ts exposes the same core through a Node transform stream for large inputs, and src/streaming/buffer holds buffering helpers shared by both paths. Tech Stack: Pure TypeScript with zero runtime dependencies, built to ESM/CommonJS/UMD via a Babel-based build pipeline (babel.config.json/babel-cjs.config.json), linted and formatted with Biome, and tested with Vitest. Code Quality: Repair behavior is covered by co-located *.test.ts files next to the modules they test (core.test.ts, stream.test.ts, index.test.ts) exercising the repair rule catalog against specific malformed-JSON fixtures; the single-file core parser trades some modularity for a tight, auditable implementation of a well-scoped problem. API Design: The public surface is deliberately minimal — one jsonrepair() function for the common case, a parallel streaming entry point for large documents, and a thin CLI wrapper — so integrating repair into an existing JSON.parse call site requires only a single import and function call.

Used by 21 apps in this directory

TypeScript
59%
Other

agenta

Developer Tools · Devops · AI Development

4,489

The open-source LLMOps platform unifying prompt engineering, evaluation, and observability for teams building reliable LLM applications.

View details
91
Repo Health
77
Technical
67
Dependency
Built with
TypeScript59%
Python39%
Updated today
TypeScript
95%
Apache 2.0

AionUi

AI Agents · Productivity

32,102

Free, open-source Cowork desktop app that unifies Claude Code, Codex, Gemini CLI, and 20+ AI agents into a single platform with multi-agent teams, 24/7 cron automation, and zero-config built-in agent.

View details
88
Repo Health
76
Technical
66
Dependency
Built with
TypeScript95%
Updated today
JavaScript
95%
MIT

AnythingLLM

Developer Tools · Automation · AI Assistants

64,914

The all-in-one AI platform for private document chat, no-code agents, and local LLMs with zero setup friction.

View details
91
Repo Health
78
Technical
68
Dependency
Built with
JavaScript95%
Updated today
TypeScript
100%
MIT

Botpress

AI Assistants · AI Development · Customer Support

14,872

The open-source hub for building and deploying LLM-powered AI agents with TypeScript-first tooling, 40+ integrations, and a revolutionary code-execution agent framework.

View details
95
Repo Health
82
Technical
66
Dependency
Built with
TypeScript100%
Updated yesterday
TypeScript
97%
Apache 2.0

Cline

AI Code Assistants

66,453

An open-source AI coding agent that lives in your editor and terminal — reads and edits your codebase, runs commands, browses the web, and requires human approval for every action by default.

View details
90
Repo Health
74
Technical
67
Dependency
Built with
TypeScript97%
Updated today
TypeScript
96%
Other

Dyad

AI Development · Productivity · AI Code Assistants

21,279

Build AI-powered apps locally with your own keys, your own models, and zero cloud lock-in.

View details
88
Repo Health
83
Technical
70
Dependency
Built with
TypeScript96%
Updated today
TypeScript
89%
Other

FastGPT

AI Agents · AI Development

29,387

Build, debug, and deploy knowledge-based AI agents with a visual workflow editor, RAG retrieval, and support for any OpenAI-compatible LLM.

View details
93
Repo Health
84
Technical
70
Dependency
Built with
TypeScript89%
Updated today
TypeScript
72%
AGPL 3.0

Firecrawl

AI Development · Developer Tools

169,311

Turn any website into clean, LLM-ready data with a single API call — no proxy headaches, no scraping complexity.

View details
89
Repo Health
83
Technical
66
Dependency
Built with
TypeScript72%
Python14%
Updated today
TypeScript
62%
Other

Flowise

Developer Tools · Automation · No Code Platforms

55,379

Drag-and-drop visual builder for AI agents, RAG pipelines, and multi-agent systems—deploy anywhere in minutes.

View details
91
Repo Health
77
Technical
64
Dependency
Built with
TypeScript62%
JavaScript27%
Updated 6 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search