Shiki
Web framework / library · Free
Syntax highlighting using TextMate grammars: generates HTML to display code in documentation, blogs, and developer interfaces.
Also known as: shikijs/shiki; shiki-syntax-highlighter; shiki

What you can use for free
Code and local use under MIT.
Paid features and costs
Computing resources, self-hosting, and external services are paid for separately if used.
Access and limitations
Code and local use under MIT. Computing resources, self-hosting, and external services are paid for separately if used.
Use cases
- Display code with syntax highlighting
- Generate highlighted HTML and add it to the documentation page
Example workflow
A possible workflow; this is not a report of hands-on testing.
Display code with syntax highlighting.
Before you start
- Web application source code and the intended workflow.
- The project's framework and runtime version.
Steps
- Choose the code block's language, grammar, and theme.
- Generate highlighted HTML and add it to the documentation page.
- Add real data and error handling; check the production build.
Check your result
- The workflow works after a page refresh and with invalid data.
- The bundle, server rendering, and supported browsers suit the project.
Choosing Shiki
Display code with syntax highlighting
Choose this when
- Display code with syntax highlighting
- Generate highlighted HTML and add it to the documentation page
Requirements
- For codeToHtml, specify lang and theme; with your own highlighter, preload the required languages and themes.
Things to consider
- Costs and limits of free use: Computing resources, self-hosting, and external services are paid for separately if used.
- Terms of use: MIT for the code; dependencies have separate licenses.
- createHighlighter and resource loading are asynchronous; the created instance is recommended to be cached rather than recreated in a hot loop.
Frequently asked questions
What can you use for free in Shiki?
Code and local use under MIT.
What additional costs might arise with Shiki?
Computing resources, self-hosting, and external services are paid for separately if used.
What terms of use matter for Shiki?
MIT for the code; dependencies have separate licenses.
How do you get started with Shiki?
Choose the code block's language, grammar, and theme. Generate highlighted HTML and add it to the documentation page. Add real data and error handling; check the production build.
Do you need CSS for each token's color?
codeToHtml returns HTML with inline styles on tokens. Shorthands load the required language/theme themselves and cache them in memory.
How do you highlight synchronously after initialization?
Create a highlighter using await createHighlighter with the langs/themes list. Then codeToHtml on that instance runs synchronously for resources already loaded; load additional resources through loadLanguage/loadTheme.
License
MIT for the code; dependencies have separate licenses.
MIT — permissive license
You can use, modify, distribute, and sell the code, including in a closed-source commercial product. When sharing copies or substantial portions of the code, retain the license text and copyright notice. You do not need to open-source your entire project; the author provides no warranties.
License termsTechnologies and topics
- Shiki
- web
- Development