jsonc-parser

A fault-tolerant scanner and parser for JSONC (JSON with comments), with SAX-style visiting, DOM trees, and edit APIs.

Library
npm
v3.3.1
768 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
68 /100 Good
Development Activity 72
Maintenance 48
Community 64
Maturity 60
Momentum 28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
80 /100 Excellent
Architecture 85
Code Quality 82
Innovation 76
Learning Curve 78

jsonc-parser is Microsoft’s scanner and parser for JSONC — JSON extended with JavaScript-style comments and trailing commas — originally built to power JSON language support in VS Code. It exposes a low-level tokenizing scanner, a fault-tolerant parse() function that still returns a best-effort result on invalid input (while reporting errors separately), a SAX-style visit() callback API, and a parseTree() function that builds a hierarchical DOM with source offsets for every node.

Beyond parsing, the package includes format() and modify() APIs that compute textual edit operations for reformatting a document or inserting/removing/replacing a property or array item, plus applyEdits() to apply them — enabling tools to make targeted, whitespace-preserving edits to a JSON/JSONC file rather than re-serializing the whole document.

What You Get

  • A low-level createScanner() tokenizer that yields tokens with offsets, line, and column information
  • A fault-tolerant parse() function that returns a best-effort JS value plus a separate list of errors
  • A SAX-style visit() API with callbacks for object/array boundaries, properties, literals, and comments
  • parseTree() to build a hierarchical DOM (Node tree) with offsets, plus findNodeAtLocation/findNodeAtOffset/getLocation helpers to navigate it
  • format() and modify() APIs that compute textual edit operations instead of requiring full re-serialization
  • stripComments() utility to convert JSONC to plain JSON

Common Use Cases

  • Parsing configuration files (tsconfig.json, VS Code settings/tasks/launch configs) that allow comments
  • Building editor tooling — syntax highlighting, outline views, or diagnostics — over JSON/JSONC documents using the scanner or visitor APIs
  • Programmatically inserting or updating a single property in a JSON config file while preserving existing formatting and comments
  • Implementing IntelliSense or path-based navigation over JSON documents via getLocation/findNodeAtLocation

Under The Hood

Architecture — the package is layered around src/impl/scanner.ts (a character-level tokenizer emitting SyntaxKind tokens with offsets/line/column), src/impl/parser.ts (which drives the scanner to implement both the SAX-style visit() callbacks and the higher-level parse()/parseTree() entry points), src/impl/edit.ts (computes textual edit operations for modify()), and src/impl/format.ts (computes formatting edits); main.ts re-exports the public surface. Because parseTree()/parse() are both built on the same underlying scanner/parser pass, offset and line/column information stays consistent whether consumers want a full DOM or a lightweight streaming visit. Tech Stack — pure TypeScript compiled to an ESM-only package (type: module, single exports entry pointing at compiled lib/esm), with zero runtime dependencies; built with tsc, linted with the flat-config ESLint + @typescript-eslint, tested via Node’s built-in --test runner rather than a separate test framework. Code Quality — src/test/ has dedicated suites for JSON parsing (json.test.ts), editing (edit.test.ts), formatting (format.test.ts), and the string-interning optimization (string-intern.test.ts); the prepack script enforces compile+test+lint before any publish, and a string-intern.ts module exists specifically to reduce allocation overhead for repeated property-name strings during parsing of large documents. API Design — the API separates concerns cleanly (scan vs. visit vs. parse vs. parseTree vs. edit) so consumers only pull in as much machinery as they need; fault tolerance is explicit rather than implicit — parse() takes an optional errors output array so callers must consciously choose to inspect parse errors, and JSDoc comments on every exported function/interface make the library usable directly from editor tooltips without external docs.

Used by 26 apps in this directory

TypeScript
71%
Other

highlight.io

Analytics · Developer Tools · Monitoring

9,384

Open-source full-stack monitoring that unifies session replay, error tracking, logging, and distributed tracing so you can stop context-switching between tools.

View details
76
Repo Health
78
Technical
65
Dependency
Built with
TypeScript 71%
Go 16%
Updated 1 weeks ago
TypeScript
68%
MIT

Hoppscotch

Developer Tools

80,676

A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.

View details
91
Repo Health
83
Technical
62
Dependency
Built with
TypeScript 68%
Vue 24%
Updated 1 weeks ago
Rust
60%
Apache 2.0

Magnitude

AI Development · Developer Tools

7,313

An open source inference engine that profiles your hardware, recommends the best local models, and tunes them for the coding agent you already use.

View details
79
Repo Health
83
Technical
71
Dependency
Built with
Rust 60%
TypeScript 25%
Updated 6 days ago
TypeScript
95%
MIT

melty

AI Code Assistants · Code Editors · Developer Tools

5,462

The AI code editor where every chat message is a git commit you can revert, branch, or squash

View details
35
Repo Health
75
Technical
67
Dependency
Built with
TypeScript 95%
Updated 1 years ago
TypeScript
60%
MIT

oh-my-claudecode

AI Agents

40,215

Multi-agent orchestration for Claude Code with zero learning curve — install as a plugin or npm CLI and coordinate parallel Claude Code agents through pre-built workflows instead of managing them by hand.

View details
85
Repo Health
70
Technical
73
Dependency
Built with
TypeScript 60%
JavaScript 39%
Updated 6 days ago
TypeScript
95%
MIT

OmniRoute

AI Agents

80,476

A free, open-source AI gateway connecting Claude Code, Codex, Cursor, Cline, and Copilot to 237 AI providers (90+ free) through one endpoint, with automatic fallback and token-compression to stretch free-tier limits further.

View details
87
Repo Health
70
Technical
70
Dependency
Built with
TypeScript 95%
Updated 6 days ago
TypeScript
97%
GPL 3.0

OpenKnowledge

Code Editors · Knowledge Management · Note Taking

4,674

A beautiful, local-first markdown IDE that turns any git repo into a live collaborative workspace for humans and AI coding agents like Claude, Codex, and OpenCode.

View details
80
Repo Health
89
Technical
64
Dependency
Built with
TypeScript 97%
Updated 6 days ago
TypeScript
99%
Other

openclaude

AI Agents · AI Code Assistants

34,123

Run Claude Code workflows against any LLM — OpenAI, Gemini, Ollama, and 200+ backends — from a single terminal-first CLI.

View details
87
Repo Health
78
Technical
71
Dependency
Built with
TypeScript 99%
Updated 6 days ago
TypeScript
90%
MIT

OpenClaw

AI Agents · AI Assistants

392,894

An open-source AI assistant that runs on your own hardware and meets you in Discord, Slack, WhatsApp, iMessage, Telegram, and 20+ other channels, with native apps for every major platform.

View details
88
Repo Health
88
Technical
66
Dependency
Built with
TypeScript 90%
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