jsonrepair

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

Library
npm
v3.15.0
2,409 stars
ISC

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
38 /100 Needs Attention
Development Activity 12
Maintenance 0
Community 40
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
79 /100 Good
Architecture 75
Code Quality 82
Innovation 72
Learning Curve 88

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

Python
71%
Apache 2.0

GPT Researcher

AI Assistants · Productivity

30,269

The pioneering open-source autonomous AI agent that conducts deep, multi-source research and produces citation-backed reports exceeding 2,000 words — faster and more reliably than any human researcher.

View details
90
Repo Health
91
Technical
64
Dependency
Built with
Python 71%
TypeScript 18%
Updated 2 weeks ago
TypeScript
95%
AGPL 3.0

HeyForm

Forms Surveys · No Code Platforms

9,048

Open-source conversational form builder with AI generation, conditional logic, and 30+ integrations — self-host with full data ownership.

View details
86
Repo Health
67
Technical
67
Dependency
Built with
TypeScript 95%
Updated 6 days ago
TypeScript
92%
Other

n8n

Automation · No Code Platforms

208,437

Code when you need it, UI when you don't — the workflow automation platform built for technical teams who refuse to choose.

View details
95
Repo Health
87
Technical
62
Dependency
Built with
TypeScript 92%
Updated 1 weeks ago
TypeScript
94%
Apache 2.0

Nanobrowser

AI Assistants · Automation · Productivity

14,163

Open-source Chrome extension for AI-powered web automation — run multi-agent browser workflows locally using your own LLM API keys, free from cloud subscriptions.

View details
80
Repo Health
66
Technical
72
Dependency
Built with
TypeScript 94%
Updated 2 weeks ago
TypeScript
97%
Apache 2.0

Next AI Draw.io

AI Design Tools · Design Tools · Developer Tools

36,393

Turn natural language into professional draw.io diagrams with AI, cloud icons, and an MCP server for your IDE.

View details
88
Repo Health
80
Technical
68
Dependency
Built with
TypeScript 97%
Updated 1 weeks ago
TypeScript
99%
Other

NocoBase

Low Code Platforms · No Code Platforms

24,686

Open-source AI + no-code platform that lets coding agents and people collaborate to build business systems fast on proven infrastructure.

View details
94
Repo Health
81
Technical
63
Dependency
Built with
TypeScript 99%
Updated 6 days ago
TypeScript
98%
Other

Novu

Developer Tools

40,195

Open-source communication infrastructure that connects your products and AI agents to every channel your users live on — Inbox, Email, SMS, Push, Chat, and more.

View details
93
Repo Health
80
Technical
64
Dependency
Built with
TypeScript 98%
Updated 6 days ago
TypeScript
90%
MIT

Plasmic

CMS · Design Tools · Low Code Platforms

7,125

The open-source visual builder that lets teams design React apps and websites with drag-and-drop while integrating seamlessly with your codebase.

View details
81
Repo Health
78
Technical
64
Dependency
Built with
TypeScript 90%
Updated 1 weeks ago
TypeScript
96%
Other

Refly

AI Development · Automation · No Code Platforms

7,537

Build deterministic, versioned agent skills from natural language—run them anywhere from Claude Code to Slack.

View details
68
Repo Health
76
Technical
63
Dependency
Built with
TypeScript 96%
Updated 1 weeks 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