@lezer/common

The packed syntax-tree data structure and parser interfaces shared by every Lezer parser

Library
npm
v1.5.2
68stars
MIT License

Repository Health

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

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
78/100Good
Architecture84
Code Quality80
Innovation82
Learning Curve65

@lezer/common provides the core syntax-tree data structure and parser abstractions that every Lezer-based parser builds on. Lezer is an incremental parser system designed for editor use (it’s the parsing engine behind CodeMirror 6’s language support), and this package defines the memory-efficient, packed tree representation that parse results are stored in, along with the Parser/Input interfaces that concrete language parsers implement.

Rather than producing a conventional AST of allocated node objects, Lezer parsers built on this package output a compact, cursor-navigable tree that can be incrementally reused across edits — critical for keeping syntax highlighting and code folding fast in a live text editor as the user types.

What You Get

  • The Tree type: a compact, packed syntax-tree representation with cursor-based traversal instead of individually allocated node objects
  • TreeCursor and SyntaxNode for navigating and inspecting parsed trees
  • The abstract Parser and Input interfaces that concrete Lezer parsers (e.g. @lezer/javascript, @lezer/python) implement
  • NodeType/NodeSet and NodeProp for attaching typed metadata to grammar node kinds
  • Tree-mixing (mix.ts) support for embedding one language’s parse tree inside another (e.g. JS inside HTML <script> tags)
  • Incremental re-parsing support so edits to a document only reparse the changed region, not the whole file

Common Use Cases

  • Building or consuming a Lezer-generated parser for a programming language inside an editor (most commonly CodeMirror 6)
  • Implementing syntax highlighting, code folding, or bracket matching against a Lezer parse tree
  • Embedding one language’s grammar inside another (e.g. CSS/JS inside HTML) via tree mixing
  • Writing editor tooling that needs incremental reparsing to stay responsive on large documents
  • Building static analysis or linting tools on top of an existing Lezer grammar’s tree output

Under The Hood

Architecture — The package is intentionally small and focused: tree.ts (~1,700 lines) implements the packed Tree/TreeBuffer/TreeCursor data structures at the core of the library, parse.ts defines the abstract Parser/PartialParser/Input interfaces concrete grammars implement, mix.ts implements the language-nesting/mixed-parsing machinery (e.g. embedding JS inside HTML), and index.ts just re-exports the public surface. Concrete language parsers (generated by the separate @lezer/generator from a grammar file) depend on this package for the tree/parser abstractions rather than reimplementing tree storage themselves — which is what keeps every Lezer-based language parser interoperable and lets CodeMirror 6 treat them uniformly.

Tech Stack — Pure TypeScript, compiled to both ESM (dist/index.js) and CJS (dist/index.cjs) via a small custom build.js using @marijn/buildtool. It has zero runtime dependencies — the packed tree format is implemented from scratch rather than wrapping an existing parsing library, which keeps it lightweight enough to load in a browser-based editor.

Code Quality — Tests live under test/test-tree.ts, run with Mocha, focused specifically on tree construction/navigation correctness (the highest-risk area given the packed binary-like tree representation). Primary development for this and Marijn Haverbeke’s other editor projects (CodeMirror, Lezer) now happens on his self-hosted Forgejo instance at code.haverbeke.berlin — the GitHub repository is a kept-in-sync mirror (commits and npm releases continue to land here), not an abandoned copy, but issues/PRs are handled upstream rather than on GitHub.

API Design — The public surface centers on a handful of well-documented types (Tree, TreeCursor, SyntaxNode, NodeType) with consistent cursor-based traversal patterns across all of them, and the canonical reference docs live on the Lezer website rather than in inline comments, so newcomers are expected to read the docs site rather than infer usage from types alone. Because this package is rarely used standalone — it’s almost always pulled in transitively by a concrete language parser or CodeMirror itself — most developers interact with a thin slice of its API (walking a SyntaxNode tree) rather than the full interface surface.

Used by 18 apps in this directory

Rust
67%
MIT

Bun

Developer Tools

95,452

An all-in-one JavaScript and TypeScript toolkit — one Rust-and-JavaScriptCore binary that replaces Node.js, npm, a bundler, and a test runner with faster equivalents.

View details
92
Repo Health
91
Technical
66
Dependency
Built with
Rust67%
C++19%
Updated today
Go
62%
Apache 2.0

Coroot

Analytics · Monitoring

7,877

eBPF-powered observability with AI root cause analysis — zero code changes required, full-stack visibility out of the box.

View details
88
Repo Health
80
Technical
65
Dependency
Built with
Go62%
Vue36%
Updated yesterday
Ruby
62%
GPL 2.0

Discourse

Community

47,672

Open-source community platform with dynamic trust levels, real-time chat, and a powerful plugin architecture for self-hosted forums.

View details
89
Repo Health
89
Technical
67
Dependency
Built with
Ruby62%
JavaScript31%
Updated today
Java
34%
Apache 2.0

Enso

Analytics · Data Engineering · Low Code Platforms

7,437

A visual and textual programming platform for data prep and analysis where the node graph and the underlying Enso code are always perfectly in sync, built by an Alteryx co-founder on a GraalVM engine.

View details
70
Repo Health
90
Technical
62
Dependency
Built with
Java34%
TypeScript27%
Scala26%
Updated 1 weeks ago
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
TypeScript
58%
AGPL 3.0

Frappe Books

Invoicing Finance

4,891

Offline desktop accounting with double-entry, POS, and custom invoice templates

View details
62
Repo Health
77
Technical
75
Dependency
Built with
TypeScript58%
Vue39%
Updated 2 months ago
Rust
69%
Other

GitButler

Developer Tools · Devops · AI Development

21,531

Git, but better — a modern version control client with stacked branches, parallel workflows, unlimited undo, and first-class support for AI-powered development.

View details
89
Repo Health
84
Technical
68
Dependency
Built with
Rust69%
TypeScript18%
Svelte12%
Updated today
TypeScript
48%
AGPL 3.0

Grafana

Monitoring · Analytics

76,300

The open-source observability platform that unifies metrics, logs, and traces from any data source into dynamic, queryable dashboards.

View details
95
Repo Health
91
Technical
65
Dependency
Built with
TypeScript48%
Go46%
Updated today
TypeScript
76%
Other

Joplin

Note Taking

56,003

The privacy-first, open-source note-taking app with end-to-end encrypted sync, AI assistance, and a powerful plugin ecosystem across every platform.

View details
93
Repo Health
87
Technical
62
Dependency
Built with
TypeScript76%
JavaScript15%
Updated yesterday

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