@codemirror/lang-json

JSON language support for the CodeMirror 6 editor: parsing, folding, indentation, and a built-in parse-error linter.

Library
npm
v6.0.2
33 stars
MIT License

Repository Health

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

Technical Analysis

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

@codemirror/lang-json adds JSON language support to the CodeMirror 6 code editor. It wraps the @lezer/json grammar in a CodeMirror LRLanguage/LanguageSupport extension, giving editor instances JSON-aware syntax parsing, code folding for objects and arrays, continued indentation, and auto-closing brackets out of the box via a single json() call.

A second, independent export, jsonParseLinter(), plugs into CodeMirror’s lint extension to surface JSON.parse syntax errors as inline diagnostics, so malformed JSON is flagged without pulling in a separate validation library. The package is intentionally small and dependency-light, following the same composition pattern as every other @codemirror/lang-* package in the CodeMirror 6 ecosystem.

What You Get

  • A json() function that returns a ready-to-use LanguageSupport extension for JSON syntax highlighting, parsing, and editing behavior
  • The underlying jsonLanguage LRLanguage object for advanced setups that need to compose or extend the language data directly
  • Code folding support for JSON objects and arrays via foldNodeProp/foldInside
  • Continued indentation on newlines inside objects and arrays, with exceptions for closing brackets
  • Auto-closing of brackets and quotes ([, {, ”) configured through languageData
  • An optional jsonParseLinter() lint source that reports JSON.parse syntax errors as inline editor diagnostics

Common Use Cases

  • Adding JSON editing support to an in-browser code editor built on CodeMirror 6 (config editors, API playgrounds, JSON viewers)
  • Building a JSON schema or config-file editing UI that needs live syntax error feedback via jsonParseLinter()
  • Embedding a lightweight JSON editor inside a larger developer tool or admin panel without shipping a full JSON validation library
  • Composing JSON support alongside other @codemirror/lang-* packages in a multi-language editor (e.g. a JSON panel next to a JS or Markdown panel)

Under The Hood

Architecture The package is a two-file extension for CodeMirror 6’s language layer. json.ts defines jsonLanguage via LRLanguage.define, wrapping a lezer JSON parser (@lezer/json) configured with indentNodeProp (continuedIndent for Object/Array except closing brackets) and foldNodeProp (foldInside for Object/Array nodes), plus languageData for closeBrackets and indentOnInput; the exported json() factory wraps that LRLanguage in a LanguageSupport instance, CodeMirror’s unit of pluggable language configuration. lint.ts is fully decoupled from parsing — jsonParseLinter() returns a linter function that runs the browser’s native JSON.parse against the document text and, on SyntaxError, regexes the error message to locate a diagnostic position via getErrorPosition. The two files share no state; the package composes CodeMirror’s LRLanguage/LanguageSupport/lint extension points rather than implementing its own parser or diagnostics engine.

Tech Stack TypeScript source compiled by @codemirror/buildhelper’s cm-buildhelper into dual ESM (dist/index.js) and CJS (dist/index.cjs) builds with matching .d.ts/.d.cts, per package.json’s exports/module/types fields. Runtime dependencies are minimal and pinned to the CodeMirror 6 line: @codemirror/language ^6.0.0 for LRLanguage/LanguageSupport/indentNodeProp/foldNodeProp, and @lezer/json ^1.0.0 for the actual JSON grammar. @codemirror/lint and @codemirror/view appear only as type imports in lint.ts, supplied by the consuming app at runtime as peers. Tests run via cm-runtests, CodeMirror’s shared cross-package test runner, and the module is sideEffects:false to support tree-shaking.

Code Quality There are no test files in this repository itself — cm-runtests follows shared CodeMirror suite conventions but no local *.test.ts exists here, so correctness leans on the upstream @lezer/json parser plus manual review. The two source files are terse (56 total lines) with triple-slash /// doc comments preceding each export, consistent with CodeMirror’s documentation-extraction tooling. Error handling in getErrorPosition() is a pragmatic regex fallback over JS engines’ JSON.parse error message formats (“at position N” / “at line L column C”), fragile across engines but guarded by an instanceof SyntaxError check and a Math.min clamp against doc.length overflow.

API Design The public surface is three exports — json() as the single entry point most consumers need, jsonLanguage for advanced language-data composition, and jsonParseLinter() as an opt-in lint source — mirroring the extension-composition pattern used across every @codemirror/lang-* package, so familiarity transfers directly from any other CodeMirror language package. The README’s usage example is a five-line drop-in with basicSetup, requiring zero configuration for the common case. The tradeoff is that linting is deliberately separate from json() (matching CodeMirror’s opt-in extension philosophy), so consumers who want parse-error diagnostics must remember to add jsonParseLinter() themselves via @codemirror/lint — a step the quick-start example doesn’t mention.

Used by 54 apps in this directory

Rust
63%
MIT

PostgresML

AI Development · Databases

6,823

Run ML training and LLM inference natively inside PostgreSQL with GPU acceleration — no data movement required.

View details
51
Repo Health
76
Technical
64
Dependency
Built with
Rust 63%
JavaScript 11%
Updated 1 years ago
Go
40%
Apache 2.0

Rill

Analytics · Data Engineering

2,962

The fastest BI tool for humans and agents — define metrics, models, and dashboards as code and query them instantly on ClickHouse or DuckDB.

View details
88
Repo Health
88
Technical
64
Dependency
Built with
Go 40%
TypeScript 38%
Svelte 21%
Updated 6 days ago
Rust
72%
Apache 2.0

Rivet

AI Agents · Developer Tools

6,326

Stateful actors as a primitive for AI agents, real-time collaboration, and durable execution — with in-memory state, WebSockets, queues, and scheduling built in.

View details
87
Repo Health
81
Technical
64
Dependency
Built with
Rust 72%
TypeScript 25%
Updated 6 days ago
TypeScript
97%
Other

Rocket.Chat

Team Chat

46,304

The secure, self-hosted team communications platform for organizations that cannot compromise on data sovereignty.

View details
96
Repo Health
79
Technical
63
Dependency
Built with
TypeScript 97%
Updated 6 days ago
Go
64%
MIT

sandboxd

Developer Tools · Devops

971

Self-hosted engine for AI app-builder products: give every user an isolated sandbox, a built-in coding agent, and a live preview URL — one command, no Kubernetes.

View details
77
Repo Health
83
Technical
68
Dependency
Built with
Go 64%
TypeScript 25%
Updated 1 weeks ago
TypeScript
67%
MIT

Scalar

Developer Tools

16,313

Beautiful, interactive OpenAPI documentation with a built-in offline-first API client and multi-language code generation — all in one open-source platform.

View details
90
Repo Health
89
Technical
65
Dependency
Built with
TypeScript 67%
Vue 29%
Updated 6 days ago
Python
79%
AGPL 3.0

Skyvern

AI Agents · Automation

23,257

Skyvern (YC S2023) automates browser-based workflows by pairing LLMs with computer vision, letting agents click, fill, and extract data on sites they've never seen, without brittle XPath selectors that break on every layout change.

View details
89
Repo Health
82
Technical
70
Dependency
Built with
Python 79%
TypeScript 19%
Updated 6 days ago
Python
100%
Other

Sourcebot

AI Code Assistants · Developer Tools · Search

4,005

A self-hosted, AI-powered code search engine that indexes every repo across GitHub, GitLab, Bitbucket, Gitea, Gerrit, and Azure DevOps, so both engineers and coding agents can search, browse, and ask questions about your codebase from one place.

View details
86
Repo Health
83
Technical
61
Dependency
Built with
Python 100%
Updated 1 weeks ago
Go
66%
GPL 3.0

Stormkit

Devops · Hosting Control Panel

264

Self-hostable platform for deploying and hosting modern web apps with automated CI/CD, custom domains, and a built-in serverless runtime — a true open-source alternative to Vercel and Netlify.

View details
80
Repo Health
79
Technical
67
Dependency
Built with
Go 66%
TypeScript 31%
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