PACKAGE · MARKDOWN

shiki

A beautiful Syntax Highlighter.

WEEKLY DOWNLOADS 7.8M
STARS 13.4K
FORKS 593
OPEN ISSUES 106
GZIP SIZE 1.7 MB
UNPACKED SIZE 602.3 kB
LAST UPDATED 3mo ago
DOWNLOAD TRENDS

shiki downloads — last 12 months

Download trends for shiki1 download series from Jun 2025 to May 2026. Use left and right arrow keys to inspect monthly values.013.6M27.2M40.8M54.4MJun 2025SepDecMarMay 2026
shiki
ABOUT SHIKI

Shiki is a powerful, high-performance syntax highlighter designed to render code snippets beautifully across various web platforms. It addresses the common challenge of presenting code clearly and accurately, supporting a wide array of programming languages and themes. The package leverages TextMate grammars, the same technology used by popular editors like VS Code, ensuring consistently accurate and feature-rich syntax highlighting.

Its core philosophy centers on accuracy, speed, and extensibility. Shiki aims to be a reliable choice for developers who need their code examples to be semantically correct and visually appealing, whether in documentation, blogs, or user-generated content. The primary audience includes frontend developers, technical writers, and anyone embedding code in a web context that requires more than basic pre-formatted text.

Shiki offers a well-defined API for programmatic use, allowing developers to parse and colorize code directly. Key functions include `getHighlighter` for asynchronous loading of languages and themes, and `codeToHtml` for converting code strings into HTML with embedded styles. It supports Onigasm, a regex engine that powers TextMate grammars, enabling complex syntax rules.

The package integrates seamlessly into modern JavaScript build tools and frameworks. It can be used server-side or client-side, making it suitable for static site generators like Next.js or Nuxt.js, as well as single-page applications built with React or Vue. Its design allows for custom theme and language definition, offering flexibility in presentation and support.

With weekly downloads of 14.6M and 13.4K GitHub stars, Shiki is a mature and widely adopted solution. Developers should note its bundle size, which at 1.7 MB (gzipped), might be a consideration for performance-sensitive client-side applications where every kilobyte counts. The package requires careful loading strategies to manage this impact.

One limitation to be aware of is the dependency on TextMate grammars and the Onigasm regex engine. While powerful, this can introduce a slight overhead compared to simpler regex-based highlighters, and the initial loading of languages and themes might require asynchronous handling to avoid blocking the main thread on the client.

WHEN TO USE
  • When generating HTML with syntax highlighting for documentation sites using static site generators.
  • When embedding code snippets in a React or Vue application that requires accurate language parsing.
  • When needing to support a diverse set of programming languages and custom themes developed for TextMate grammars.
  • When programmatically converting markdown files with code blocks into HTML on the server.
  • When prioritizing accurate syntax highlighting that closely matches desktop IDEs like VS Code.
  • When leveraging Shiki's `codeToHtml` function for direct string-to-HTML code conversion.
WHEN NOT TO USE
  • If your application requires a syntax highlighter with a significantly smaller client-side bundle size and basic highlighting is sufficient.
  • When the overhead of TextMate grammar parsing is not justifiable for very simple syntax requirements.
  • If you are building a purely static HTML export where JavaScript execution for highlighting is undesirable.
  • When you have extremely constrained network conditions on the client and need to minimize initial JavaScript payloads.
  • If your project only requires highlighting for a single, simple language that can be handled by a lighter-weight solution.

CORRECTIONS

Spot wrong data here?

A short note helps us fix it.

Anonymous · No account · No email back

COMPARISONS 4
shiki vs @mdx-js/react ★ 19.6K · 7.9M/wk shiki vs marked ★ 36.9K · 22.8M/wk shiki vs remark ★ 8.7K · 2.2M/wk shiki vs rehype ★ 2.2K · 2.0M/wk