Highlight code at native speed
@pierre/chamele is a fast code highlighter written by hand in WebAssembly Text. It ships with built-in language lexers, works across runtimes, and speaks familiar Shiki-compatible formats. Made by The Pierre Computer Company.
57.4 kB gzipped Wasm · 49 built-in languages · 92–771× faster than Shiki (Benchmark)
source.ts
123456789101112131415161718192021/** * An interface for a point in 2D space. */interface Point { x: number; y: number;}
/** * Calculates the distance between two points. * @param {Point} a - The first point. * @param {Point} b - The second point. * @returns The distance between a and b. */function distance(a: Point, b: Point): number { const dx = a.x - b.x; const dy = a.y - b.y; return Math.hypot(dx, dy);}
console.log(distance({ x: 0, y: 0 }, { x: 3, y: 4 }));Fast, familiar, and editor-ready.
Native WebAssembly performance, Shiki-compatible output, and incremental tokenization built for editors.
Native performance
- One-pass lexers
- Hand-written Wasm lexers emit HTML or token records directly, with no AST or grammar runtime.
- Zero-copy output
codeToHtml()returns a view into WebAssembly memory, ready for a response, file, or decoder.- SIMD scans
- Hot paths read 16 bytes per step, and equal styles share spans across whitespace.
Shiki compatibility
- Familiar APIs
- Use
codeToHtml(),codeToTokens(), andcodeToHast()in familiar highlighting workflows. - Tokens & HAST
- Render Shiki-compatible themed tokens or HAST with decorations and transformers.
- Themes included
- Use bundled Zed themes or supply your own light and dark theme objects.
Editor friendly
- Incremental edits
LiveTokenizerre-tokenizes only lines whose text or lexer state changed.- Visible-range rendering
- Bound synchronous work to the viewport while off-screen lines converge in the background.
- Precise updates
- Every edit reports exactly which lines changed, leaving untouched rows alone.
With love from The Pierre Computer Company
Collectively, our team brings over 150 years of expertise designing, building, and scaling the world's largest distributed systems at Cloudflare, Coinbase, Discord, GitHub, Reddit, Stripe, X, and others.