syntax-highlighter-bench

This is a benchmark of JS syntax highlighters: fuz_code, Twinkleplop, Prism, and Shiki with each of its two engines, run on the same inputs through one adapter each. It times throughput and cold start on one named machine, and measures bundle size, install footprint, retained memory, and the size of each library's output: how many tokens it splits an input into, and the bytes of its HTML.

The maintainer of this benchmark also maintains fuz_code, so that library is marked wherever it appears, every input is labeled by where it came from, and the method is published for anyone to reproduce.

The libraries have different features. Shiki highlights with the TextMate grammars and themes VS Code uses; Twinkleplop aims for a similar feature set, with its own themes, annotations, and Twoslash support; and both do more than fuz_code, which has the fewest features of the four: a single-pass lexer per language, with CSS classes for its theme. Their fidelity differs too: how finely each splits the same source, and how accurately it classifies each part. These numbers compare the work all of them share, not what one offers that another doesn't, and they time each library's output without scoring its quality.

They also lex differently, and the throughput figures reflect it. fuz_code's lexers scan the source once, without regular expressions, and write their tokens into one typed array that the next call reuses. Twinkleplop compiles a grammar declared for each language and runs it, then passes the tokens through the language's reclassifiers. Prism matches the regular expressions of a grammar. Shiki runs TextMate grammars on a regular-expression engine, Oniguruma compiled to wasm or the JS engine's own, and resolves each token's theme color as it goes. A lexer written for one language can do less work for each byte than an engine that runs a grammar, and gives up the grammar: fuz_code's lexers don't read TextMate grammars or VS Code themes, differ from an editor's highlighting in some edge cases, and a new language is a lexer to write, not a grammar to load.

AI disclosure: this is an LLM-generated repo guided by a person.

Headline figures

Each bar's ratio is to the best library in the chart, where 1.00× is the best and a ratio marked ≈ is inside the row's noise floor: the machine's for throughput, and the heap check's tolerance for retained memory. Hover a bar to compare the others against it instead.

Tokenizing
Twinkleplop 63.4 MB/s 3.68×
Prism 14.8 MB/s 15.7×
Shiki (JS engine) 1.57 MB/s 148×
Shiki (wasm) 1.15 MB/s 202×
fuz_codemaintainer's 233 MB/s 1.00×

higher is better — MB/s over the neutral inputs, geometric mean over 27 of 27 rows

Highlighting to HTML
Twinkleplop 34.8 MB/s 1.97×
Prism 7.91 MB/s 8.69×
Shiki (JS engine) 1.04 MB/s 66.1×
Shiki (wasm) 0.86 MB/s 79.7×
fuz_codemaintainer's 68.8 MB/s 1.00×

higher is better — MB/s over the neutral inputs, geometric mean over 27 of 27 rows

Cold start to a first highlight
Twinkleplop 11.2 ms 4.69×
Prism 6.20 ms 2.59×
Shiki (JS engine) 114 ms 47.6×
Shiki (wasm) 125 ms 52.2×
fuz_codemaintainer's 2.39 ms 1.00×

lower is better — ms a bundled library adds to a fresh Node process, geometric mean over the languages over 9 of 9 rows

Retained memory
Twinkleplop 1.33 MB 8.42×
Prism 292 kB 1.84×
Shiki (JS engine) 4.08 MB 25.8×
Shiki (wasm) 27.5 MB 174×
fuz_codemaintainer's 158 kB 1.00×

lower is better — what a library holds after loading one language and highlighting a small snippet once: V8 heap, machine code, and external memory, geometric mean over the languages over 9 of 9 rows

Everything a page loads
Twinkleplop 55.1 kB 4.52× JS 53.0 kB · no wasm binary · theme stylesheet 2.13 kB · theme: light + dark
Prism 12.2 kB 1.00× JS 11.5 kB · no wasm binary · theme stylesheet 657 B · theme: light
Shiki (JS engine) 123 kB 10.1× JS 123 kB · no wasm binary · no stylesheet: the theme is in the JS · theme: light
Shiki (wasm) 263 kB 21.6× JS 105 kB · wasm binary 159 kB · no stylesheet: the theme is in the JS · theme: light
fuz_codemaintainer's 14.0 kB 1.15× JS 13.4 kB · no wasm binary · theme stylesheet 643 B · theme: light + dark

lower is better — the JS, wasm binary, and theme stylesheet of the docs set (js, ts, css, html, md, bash, json), each compressed on its own with gzip

Timed on laptop1 (AMD Ryzen 5 PRO 7530U with Radeon Graphics, Node v24.14.1) on 2026-10-12 at commit 340492a991. The machine's noise floor is 2.4% for one cell and 0.1% for a geometric mean: a smaller difference is not a result.

The machine and the run

laptop1: AMD Ryzen 5 PRO 7530U with Radeon Graphics, 12 threads, performance governor, amd-pstate-epp driver, energy preference performance, boost on, 14.4 GB, kernel 6.12.90+deb13.1-amd64. Corpus e649d70d43. The anchor, a fixed workload read before and after measuring, drifted 1.1%: stable. Two processes measuring the same library on the same cell in this run were 4.0% apart at the 95th percentile and 0.9% at the median, against 4.0% at the 95th percentile in the calibration.

These numbers are the run's own, a snapshot of what it measured. Since then: fuz_code was measured at 0.52.1 and is now at 0.56.0.

These are summaries. The results page has every cell behind them, on inputs from other sources too. The caveats say what the numbers don't.

What the numbers mean in practice

Whether a ratio matters depends on where the highlighting runs and how often, and so does which figure to read first:

  • At build time, as a static site or documentation build highlights its pages once: throughput is the only figure that matters, and only to the build's time. Readers get plain HTML, so the JS and the cold start never reach them, though a theme stylesheet still does.
  • In the browser: everything a page loads and the cold start to a first highlight come first, then throughput on long pages.
  • In an editor that highlights as you type: throughput at the size being edited, against the time of one frame.
  • On a server that renders each request: throughput and retained memory, paid on every request and held by every process.
  • In serverless and edge functions: the cold start, paid by every fresh instance, and the bundle where the platform limits its size.

The HTML throughput worked out for sizes a reader knows. Each figure applies the geometric-mean rate over the neutral inputs to that size, so it is an estimate; a library's rate differs from input to input, as the results page shows.

worked out forTwinkleplop Prism Shiki (JS engine) Shiki (wasm) fuz_codemaintainer's
Highlighting to HTML, at the neutral geometric mean over 27 of 27 rows
one 10 kB code block 0.29 ms 1.97× 1.26 ms 8.69× 9.61 ms 66.1× 11.6 ms 79.7× 0.15 ms 1.00×
10 kB blocks in one 16 ms frame whole blocks 55 12 1 1 110
1 MB of source as a site build might highlight 28.7 ms 1.97× 126 ms 8.69× 961 ms 66.1× 1,159 ms 79.7× 14.5 ms 1.00×

What each language costs

The JS a page loads for its languages, minified and gzipped: several in one bundle, then each language alone. Each bundle holds the library's runtime, shown alone in the first row, which highlights nothing by itself. Everything a page loads above gives one set's total, with the wasm binary and theme stylesheet beside the JS.

How to read this table

A bundle of several languages is smaller than the sum of their bundles, since it holds the runtime once and shares what the languages share, as TypeScript shares JS. The bars of each group are on one scale, and beside a number is its ratio to the smallest in the row. The results page has what each language adds over the runtime, and what one more language adds to a bundle that holds the others.

languageTwinkleplop Prism Shiki (JS engine) Shiki (wasm) fuz_codemaintainer's
The runtime the library with no language: it highlights nothing alone, and every bundle below holds it
core 18.7 kB 14.3× 3.56 kB 2.71× 56.6 kB 43.1× 38.9 kB 29.6× 1.31 kB 1.00×
Several languages one bundle of them all, runtime included
docs js, ts, css, html, md, bash, json 53.0 kB 4.60× 11.5 kB 1.00× 123 kB 10.7× 105 kB 9.11× 13.4 kB 1.16×
every timed language ts, js, css, html, json, svelte, md, bash, rust 56.4 kB 4.44× 12.7 kB 1.00× 129 kB 10.2× 111 kB 8.76× 15.9 kB 1.25×
One language the whole bundle of a page that highlights only this language, runtime included
TypeScript 47.5 kB 8.35× 5.69 kB 1.00× 72.3 kB 12.7× 54.5 kB 9.59× 6.11 kB 1.07×
JS 44.5 kB 8.32× 5.35 kB 1.00× 72.7 kB 13.6× 55.0 kB 10.3× 6.11 kB 1.14×
CSS 29.8 kB 11.9× 4.11 kB 1.64× 68.9 kB 27.6× 51.2 kB 20.5× 2.50 kB 1.00×
HTML 44.5 kB 6.75× 6.60 kB 1.00× 95.9 kB 14.5× 78.4 kB 11.9× 9.08 kB 1.38×
XML — unsupported: no xml4.51 kB 1.23× 61.5 kB 16.8× 43.8 kB 12.0× 3.66 kB 1.00×
JSON 19.3 kB 9.63× 3.77 kB 1.88× 57.2 kB 28.5× 39.5 kB 19.7× 2.01 kB 1.00×
Svelte 45.6 kB 6.55× 6.96 kB 1.00× 104 kB 14.9× 86.0 kB 12.4× 9.75 kB 1.40×
Markdown 22.4 kB 4.49× 6.21 kB 1.24× 62.1 kB 12.4× 44.4 kB 8.90× 5.00 kB 1.00×
Bash 31.6 kB 6.75× 6.60 kB 1.41× 62.5 kB 13.4× 44.8 kB 9.58× 4.67 kB 1.00×
Rust 32.0 kB 8.21× 4.67 kB 1.20× 59.2 kB 15.2× 41.4 kB 10.6× 3.90 kB 1.00×

Coverage

Which languages each library is measured on. They are fuz_code's built-in set, so the list favors it. Prism and Shiki each support hundreds of languages, and none of that shows here.
languageTwinkleplopPrismShiki (JS engine)Shiki (wasm)fuz_codemaintainer's
TypeScript ts yesyesyesyesyes
JS js yesyesyesyesyes1
CSS css yesyesyesyesyes
HTML html yesyesyesyesyes
XML xml not timed— unsupportedyes2yes3yes3yes
JSON json yesyesyesyesyes
Svelte svelte yesyes4yesyesyes
Markdown md yesyesyesyesyes
Bash bash yesyesyesyesyes
Rust rust yesyesyesyesyes
  1. the TypeScript lexer, which fuz_code registers for JS
  2. the markup grammar, which Prism also registers as xml
  3. the XML grammar embeds the Java grammar, which loads with it
  4. the third-party prism-svelte grammar

Unsupported means the library's adapter doesn't claim the language, and is never shown as a zero or counted in a mean. Languages and sets has the details.

Libraries

The measured libraries, at the versions these results came from.
libraryversionHTML outputenginedefault theme's color schemeswhat is measured
Twinkleplop twinkleplop @twinkleplop/core 0.3.1
with
  • @twinkleplop/bash 0.1.7
  • @twinkleplop/css 0.1.7
  • @twinkleplop/html 0.1.7
  • @twinkleplop/javascript 0.1.7
  • @twinkleplop/json 0.1.7
  • @twinkleplop/markdown 0.2.1
  • @twinkleplop/rust 0.1.7
  • @twinkleplop/svelte 0.1.7
  • @twinkleplop/typescript 0.1.7
  • @twinkleplop/theme-github 0.2.4
classesgrammar VMlight + dark

The full pipeline: the grammar plus the language's reclassifier stack, as shipped.

Prism prism prismjs 1.30.0
with
  • prism-svelte 0.5.0
classesregex grammarslight

The core plus one component file per grammar, without the autoloader or any plugin.

Shiki (JS engine) shiki_js shiki 4.5.0 inline stylesTextMate grammarslight

The JS RegExp engine. The HTML carries inline styles rather than classes.

Shiki (wasm) shiki_wasm shiki 4.5.0 inline stylesTextMate grammarslight

The Oniguruma wasm engine, Shiki's default. The HTML carries inline styles rather than classes.

fuz_code fuz_code
maintainer's this benchmark's maintainer also maintains it
@fuzdev/fuz_code 0.52.1 classessingle-pass lexerslight + dark

Single-pass lexers. tokenize is the lexer alone and html adds the renderer.

Each library is driven through one adapter with notes on the entry points it uses, so its maintainers can review or replace it. See the adapters.