@lezer/highlight

Syntax highlighting framework that maps Lezer parse trees to styleable highlighting tags

Library
npm
v1.2.5
41 stars
MIT License

Repository Health

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

Technical Analysis

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

@lezer/highlight is the syntax highlighting layer of the Lezer parser system used by CodeMirror. It defines a mostly closed vocabulary of highlighting tags, lets language packages associate tree nodes with those tags, and provides highlighters that turn tagged nodes into CSS classes or inline styles.

Rather than matching raw token strings, it works over structured Lezer parse trees, so highlighting stays consistent across languages and themes. It ships as a tiny, dependency-light TypeScript library that powers highlighting for every CodeMirror 6 language mode.

What You Get

  • A closed, extensible vocabulary of highlighting tags (tags) shared across all Lezer languages
  • styleTags to associate syntax tree node types with highlighting tags in a language grammar
  • tagHighlighter and the ready-made classHighlighter for turning tags into CSS classes
  • highlightTree and highlightCode to walk a parse tree and emit styled ranges or DOM
  • Tag modifiers and inheritance so themes can fall back from specific to general tags

Common Use Cases

  • Adding syntax highlighting to a CodeMirror 6 editor via a language package
  • Authoring a new Lezer language mode that exposes highlighting metadata
  • Rendering static, highlighted code snippets outside an editor with highlightCode
  • Building custom editor themes that map highlighting tags to CSS classes

Under The Hood

Architecture - The entire library lives in a single src/highlight.ts module built around a Tag class whose instances form a specificity-ordered set of parent tags, with Modifier instances lazily generating modified tags and caching them via a power-set of parent configurations. styleTags compiles a selector spec into a Rule linked list stored on nodes through a ruleNodeProp NodeProp; highlightTree and highlightCode then drive a HighlightBuilder that walks the tree with a TreeCursor, resolves the active tags via getStyleTags, and calls a Highlighter to emit class names for each styled range. Tech Stack - Written in TypeScript targeting both ESM and CommonJS (dist/index.js and dist/index.cjs), its only runtime dependency is @lezer/common for tree and NodeProp primitives, and it builds with @marijn/buildtool and TypeScript 5. Code Quality - The code is dense but carefully commented with /// doc comments feeding the generated API reference, uses precise readonly types and internal markers, and favors small pure helpers (sameArray, powerSet); there is no test directory in the repository, so correctness relies on the broader Lezer/CodeMirror integration suite rather than local unit tests. API Design - The public surface is small and composable - tags, styleTags, tagHighlighter/classHighlighter, and highlightTree/highlightCode - with a closed tag vocabulary and inheritance that lets themes cover many languages with minimal boilerplate, though understanding the tag/modifier model takes some reading of the reference docs.

Used by 47 apps in this directory

TypeScript
99%
MIT

Sanity

CMS

6,370

Open-source headless CMS with a fully customizable React Studio, real-time collaborative editing, structured content modeling, and GROQ query language

View details
92
Repo Health
90
Technical
66
Dependency
Built with
TypeScript 99%
Updated yesterday
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 yesterday
TypeScript
92%
Other

Suna

AI Agents

20,306

Turn your company into a git repo — one config, one command center, a workforce of AI agents that runs the real work around the clock.

View details
90
Repo Health
79
Technical
65
Dependency
Built with
TypeScript 92%
Updated yesterday
TypeScript
85%
Apache 2.0

superset

AI Code Assistants · AI Development

15,503

Orchestrate an army of AI coding agents—Claude Code, Codex, Gemini CLI, and more—running simultaneously in isolated git worktrees from a single Electron desktop app.

View details
86
Repo Health
80
Technical
64
Dependency
Built with
TypeScript 85%
Updated yesterday
TypeScript
99%
Other

Teable

Databases · No Code Platforms

21,920

A no-code PostgreSQL database with spreadsheet UX, real-time collaboration, and native AI agents — built for teams that outgrow Airtable.

View details
78
Repo Health
76
Technical
62
Dependency
Built with
TypeScript 99%
Updated 2 days ago
Go
75%
AGPL 3.0

Teleport

Authentication · Security

21,016

Zero-trust infrastructure access platform that replaces credentials and VPNs with short-lived certificates, SSO, and identity-aware proxies for SSH, Kubernetes, databases, RDP, and AI agents.

View details
94
Repo Health
81
Technical
68
Dependency
Built with
Go 75%
TypeScript 16%
Updated 5 days ago
Rust
79%
Apache 2.0

TensorZero

Ab Testing Experimentation · AI Development · Monitoring

11,708

TensorZero unifies the LLM gateway, observability, evaluation, optimization, and experimentation stack behind a single OpenAI-compatible API, built in Rust for sub-millisecond p99 latency.

View details
53
Repo Health
87
Technical
68
Dependency
Built with
Rust 79%
TypeScript 15%
Updated 4 months ago
TypeScript
68%
AGPL 3.0

Tolaria

Note Taking

20,161

A free, open-source, local-first desktop app for managing markdown knowledge bases on macOS, Windows, and Linux — for second brains, company docs, or AI assistant memory and procedures.

View details
84
Repo Health
71
Technical
68
Dependency
Built with
TypeScript 68%
HTML 15%
Updated yesterday
Python
68%
AGPL 3.0

Tracecat

AI Agents · Automation · Security

3,860

Open-source agentic security automation platform that runs AI agents and durable workflows at scale with sandboxed execution.

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