# Experimental WebGPU highlighter trades language grammars for a tiny model
*Event date: 2026-09-09*
An experimental syntax-highlighting project is testing whether a small model running through WebGPU can color source code without the language-specific grammars used by conventional highlighters. The project, called gpu-lexer, presents a 27.5KB browser bundle and applies the same model across programming languages.
Instead of parsing code according to a declared language, gpu-lexer first separates an input file into basic pieces such as words, spaces, line breaks and symbols. A compact model then considers both nearby tokens and broader file context before assigning each piece to a display class. Adjacent pieces with matching labels are combined into the spans returned to the calling application.
The approach is meant to make the highlighter language-agnostic. Its demonstration says the model can attempt to label unfamiliar languages and syntax because it infers token roles from context rather than loading a matching grammar. The output classes have been normalized to nine categories, including comments, strings, numbers, keywords, types, functions, constants and operators, alongside plain text.
The developer is explicit that the experiment is not equivalent to a grammar-driven highlighter. On files excluded from training, 12.57% of the model's token labels differed from those produced by Shiki. That figure measures agreement with Shiki rather than an objective error rate, and the project warns that performance on unseen languages or ordinary real-world repositories may diverge further.
The published comparison used 1,069 held-out files covering the top 25 languages in the GitHub Innovation Graph for the first quarter of 2026. Results were weighted by each language's pusher count, while unsupported languages received a score of zero. Shiki served as the normalization reference, with competing tools' token names translated into the same nine output classes.
A separate browser benchmark tested a 5.56-million-character input made from repeated copies of three.min.js. It ran after one warm-up on a MacBook Pro with an Apple M4 Pro, a 20-core GPU and 24GB of memory, using Chrome 152 on macOS 26.6.2. Each highlighter ran in a dedicated worker, and the comparison excluded DOM rendering. The tools also returned different data structures, a caveat that limits direct conclusions from raw timing.
The bundle measurements were taken from minified, Brotli-compressed browser builds on September 8. Unlike grammar collections whose size can rise as language coverage expands, gpu-lexer uses one bundle for every language. That is the central trade-off: a compact universal classifier in place of deterministic language definitions.
For developers, the project is best viewed as a technical demonstration rather than a drop-in guarantee of accurate highlighting. Its value lies in showing that WebGPU can support a small contextual model directly in the browser. Whether that model's flexibility outweighs disagreement with established grammars will depend on the code, languages and accuracy requirements of the application using it.



