A fast, zero-dependency, synchronous lexical syntax highlighter. Try it in the online playground.
- Unified. One shared grammar spec compiled into native runtimes for Go, Rust, JS/TS, and Zig (plus a prebuilt C99 ABI library), producing identical tokens across targets.
- Compact. Zero runtime dependencies, bytecode-driven grammars, selective imports, and 48-330 MB/s end-to-end HTML throughput.
- Self-contained. Ships with 97 languages and 25 themes, offline language detection, HTML and 24-bit ANSI renderers, zero-copy token streaming, resumable incremental scanning, and framework integrations.
Note
limn is a lexical highlighter. It does not build an AST or resolve symbols across scopes; use Tree-sitter or Shiki when you need semantic highlighting or VS Code TextMate scope parity.
Syntax highlighters usually make you give up at least one of speed, size, or highlighting quality:
- TextMate & parser engines (Shiki, syntect, Tree-sitter) maximize accuracy, but pull in Oniguruma, async WASM loaders, or multi-megabyte grammar bundles and run around 1 MB/s.
- Regex lexers (Prism, highlight.js, Chroma) are lighter to embed, but backtrack on regexes, break on stateful edge cases (nested interpolation, raw strings, embedded languages), and diverge across ecosystems.
limn targets the sweet spot across all three: a zero-dependency bytecode scanner VM that handles stateful syntax cleanly, stays compact (selective imports, compact JS bundle for all 97 languages, 25 themes, and offline detection), and runs synchronously at 48-330 MB/s with identical tokens across every runtime.
| Target | Install | Integrations |
|---|---|---|
| Go | go get github.com/ekesti/limn |
goldmarklimn |
| Rust | cargo add limn-hl |
limn-ratatui, limn-pulldown-cmark |
| JS / TS | npm install limn-hl |
@limn-hl/rehype, @limn-hl/markdown-it, @limn-hl/marked |
| Zig | zig fetch --save git+https://github.com/ekesti/limn |
- |
| C99 | GitHub Releases (liblimn + limn.h) |
- |
| CLI | go install github.com/ekesti/limn/cmd/limn@latest |
- |
JavaScript / TypeScript:
import { detect } from "limn-hl/detect";
import { all } from "limn-hl/lang";
import { HtmlRenderer } from "limn-hl/render";
import { tokyoNight } from "limn-hl/theme";
const src = `export const greet = (name: string) => \`hi \${name}\`;\n`;
const html = new HtmlRenderer({ theme: tokyoNight }).highlight(all(), src, detect(src));Go:
reg := lang.All()
html := render.NewHTML(render.HTMLOptions{Theme: &theme.TokyoNight}).
Highlight(reg, src, limn.Detect(src))Rust:
let reg = limn::lang::all();
let renderer = limn::render::HtmlRenderer::new(limn::render::HtmlOptions {
theme: Some(&limn::theme::TOKYO_NIGHT),
..Default::default()
});
let html = renderer.highlight(reg, src, limn::detect(src));See docs/usage.md for full examples (including Zig, C, CLI, ANSI output, CSS variables, token streaming, and bundle/binary size tuning) and docs/integrations.md for Markdown, Ratatui, React, and Vue usage.
Using limn
docs/usage.md: Full per-runtime examples (Go, Rust, JS/TS, Zig, C, CLI), API reference, HTML/CSS styling, and size tuning.docs/integrations.md: Official adapters (@limn-hl/rehype,@limn-hl/markdown-it,@limn-hl/marked,goldmarklimn,limn-ratatui,limn-pulldown-cmark) and React/Vue recipes.docs/languages.md: Supported 97 languages, aliases, Cargo feature groups, and 25 built-in themes.docs/benchmarks.md: Tokenization throughput, HTML comparison, bundle/binary sizes, and reproduction steps.
Internals & Contributing
docs/vm.md: Compiler pipeline, bytecode VM instruction set, dispatch tables, and offline detector architecture.CONTRIBUTING.md: Adding languages and themes, running cross-runtime verification, retraining the detector, and releasing.AI_POLICY.md: Guidelines for AI-assisted issues, PRs, grammar fixes, and VM changes.tools/detect/README.md: Offline detector training toolchain and Go highlight-equivalence scorer.
End-to-end HTML highlighting throughput on ~3-4 KB source files (higher is better; tokenization numbers up to 1 GB/s, bundle/binary sizes, and reproduction steps in docs/benchmarks.md):
| Ecosystem | Library | sample.go |
sample.js |
sample.rs |
sample.json |
vs. limn |
|---|---|---|---|---|---|---|
| Go | limn | 195.81 MB/s | 140.61 MB/s | 182.04 MB/s | 223.23 MB/s | baseline |
| Go | Chroma (v2.27.0) |
1.02 MB/s | 1.20 MB/s | 0.95 MB/s | 2.99 MB/s | 75x to 192x slower |
| Rust | limn | 282.16 MB/s | 192.72 MB/s | 242.79 MB/s | 331.27 MB/s | baseline |
| Rust | syntect (5.3.0, onig) |
2.54 MB/s | 1.02 MB/s | 2.05 MB/s | 5.00 MB/s | 66x to 189x slower |
| Node.js | limn | 87.28 MB/s | 48.08 MB/s | 70.28 MB/s | 91.01 MB/s | baseline |
| Node.js | Prism (1.30.0) |
16.81 MB/s | 6.08 MB/s | 10.97 MB/s | 16.96 MB/s | 5.2x to 7.9x slower |
| Node.js | highlight.js (11.12.0) |
15.08 MB/s | 3.40 MB/s | 10.39 MB/s | 4.19 MB/s | 5.8x to 21.7x slower |
| Node.js | Shiki (4.6.0) |
0.68 MB/s | 0.49 MB/s | 0.72 MB/s | 1.56 MB/s | 58x to 128x slower |
MIT. Made by Ray & Ekesti Labs with