@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
33stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
26/100Needs Attention
Development Activity12
Maintenance0
Community20
Maturity60
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
69/100Good
Architecture72
Code Quality55
Innovation70
Learning Curve78

@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 52 apps in this directory

Go
72%
GPL 3.0

1Panel

Devops · Hosting Control Panel · Monitoring

36,573

The only open-source VPS control panel with native AI agent runtime — deploy websites, Docker stacks, and local LLMs from one web interface.

View details
91
Repo Health
76
Technical
67
Dependency
Built with
Go72%
Vue28%
Updated today
TypeScript
99%
Other

Activepieces

Automation · AI Assistants

23,887

Open-source AI automation platform that converts 280+ workflow integrations into MCP servers for LLMs, with no-code builders and TypeScript extensibility.

View details
92
Repo Health
85
Technical
65
Dependency
Built with
TypeScript99%
Updated today
Python
66%
Apache 2.0

Agent Control

AI Agents

295

An open-source runtime control plane for AI agents — define safety guardrails once, apply them across agents built on LangChain, CrewAI, Google ADK, or AWS Strands, and update controls without redeploying code.

View details
79
Repo Health
71
Technical
70
Dependency
Built with
Python66%
TypeScript33%
Updated yesterday
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
TypeScript
69%
Other

Budibase

Low Code Platforms · No Code Platforms

28,220

Build AI agents, automations, and internal apps on a single open-source platform with full self-hosting control.

View details
92
Repo Health
81
Technical
63
Dependency
Built with
TypeScript69%
Svelte26%
Updated today
TypeScript
99%
AGPL 3.0

Cherry Studio

AI Assistants

50,753

All-in-one AI desktop client with 300+ assistants and multi-model support

View details
88
Repo Health
84
Technical
71
Dependency
Built with
TypeScript99%
Updated today
TypeScript
92%
MIT

Dittofeed

Marketing · Automation

2,903

Open-source omni-channel customer engagement platform for automating transactional and marketing messages via email, SMS, WhatsApp, Slack, and mobile push.

View details
54
Repo Health
75
Technical
63
Dependency
Built with
TypeScript92%
Updated 4 months ago
TypeScript
99%
Other

Dokploy

Devops · Hosting Control Panel · Security

36,702

Self-hosted PaaS that deploys apps and databases on your own VPS using Docker, Traefik, and multi-build-system orchestration

View details
89
Repo Health
76
Technical
65
Dependency
Built with
TypeScript99%
Updated yesterday
TypeScript
72%
Other

Epicenter

Knowledge Management · Note Taking · Developer Tools

4,761

A local-first monorepo led by Whispering, an open-source speech-to-text app, built on an MIT toolkit that turns your data into plain Markdown and SQLite files you own instead of a database you rent.

View details
88
Repo Health
90
Technical
68
Dependency
Built with
TypeScript72%
Svelte15%
Updated today

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