TanStack
Getting Started

Comparison

Comparison

Syntax highlighters solve different problems. The smallest correct choice is the one whose architecture matches your output requirements.

Decision table

ChooseBest fitMain tradeoff
TanStack HighlightBlogs and docs that know their languages, need SSR/client parity, and value small HTML and selective importsFocused heuristics instead of editor-grade grammars
Sugar HighThe smallest practical JavaScript/TypeScript/JSX experienceNarrower language set and much more generated markup in our fixture comparison
ShikiVS Code-like accuracy, TextMate grammars, and broad language/theme compatibilityMuch larger runtime and asynchronous setup
highlight.jsBroad language coverage and optional automatic detectionLarger modular core and detection/parser work not needed by known-language docs
PrismMature grammar ecosystem and plugin integrationsGrammar composition and plugin architecture add more surface than this use case needs
speed-highlightSmall, modular, class-based highlighting across browser and terminal use casesDifferent grammar/output model and fewer docs-specific adapters
Starry NightGitHub-like TextMate scopes and very broad grammar coverageLarge grammar/WASM footprint

Capability matrix

CapabilityTanStack HighlightSugar HighShikihighlight.jsPrism
Synchronous highlightingYesYesAfter initializationYesYes
Explicit per-language importsYesPartialYesYesYes
Known-language docs focusYesJS/TS focusNoNoNo
Class-based token colorsYesCSS variables and inline token dataInline colors by defaultYesYes
One markup tree for light/darkYesTheme through CSS variablesDual-theme output supportedTheme CSSTheme CSS
Built-in line decorationsYesLine class callbackTransformersNoPlugins
Built-in character-range decorationsYesNoTransformersNoPlugins
HTML script/style delegationRegistered languagesNo general embeddingGrammar-drivenGrammar-drivenGrammar-driven
Markdown fence delegationRegistered languagesNoGrammar-drivenGrammar-drivenGrammar-driven
Remark, rehype, and Octane MDX adaptersYesNoEcosystemEcosystemEcosystem
Automatic language detectionNoNoNoYesNo
TextMate/VS Code compatibilityNoNoYesNoNo
Hundreds of languagesNoNoYesYesYes

"Partial" means the package offers separate presets or registrations, but not the same one-definition-per-language import model.

Measured overlap with Sugar High

The repository compares its installed Sugar High version against the overlapping JavaScript, TypeScript, JSX, and TSX fixture set. Timings are the median of three samples after two warmup passes. Bundle KB uses 1,000 bytes; HTML sizes count UTF-8 bytes.

Bundle gzip5,040-block runtimeGenerated HTML
TanStack Highlight4.11 KB78 ms6.7 MiB
Sugar High 1.2.13.28 KB377 ms44.8 MiB

Sugar High wins raw JavaScript bundle size. TanStack Highlight spends about 830 additional gzip bytes on its registry, class-based output, decorations, and broader context handling, then produces substantially less HTML in this corpus.

Measured overlap with Shiki

Across 334 committed documentation fixtures:

InitializationLanguage loadingWarmed highlightingGenerated HTML
TanStack HighlightNoneNone4.6 ms365 KiB
Shiki 4.3.122 ms47 ms182 ms1,257 KiB

The script reports language loading separately and falls back to plaintext for EJS, ENV, and TSRX in Shiki. Timings vary by machine. This is not equivalent work: Shiki provides much deeper grammar accuracy and compatibility. The benchmark describes the cost difference when both are used to render this package's targeted docs corpus.

When not to use TanStack Highlight

Choose another tool when you need:

  • Exact editor or compiler tokenization
  • VS Code theme imports
  • TextMate grammar compatibility
  • Language auto-detection
  • Hundreds of languages
  • Incremental editor state
  • Semantic tokens from a language service

Run pnpm run compare:sugar-high and pnpm run compare:shiki to reproduce the repository's comparisons.