starry-night is a JavaScript syntax-highlighting library that aims to reproduce the high-quality code highlighting used by GitHub.
It processes code with TextMate grammars and returns a hast syntax tree, allowing the result to be rendered as HTML, React components, ANSI output or other formats.
The library supports more than 600 grammars, including programming languages, markup formats, configuration files and other specialised syntax. Developers can load a compact selection of common grammars, the complete collection or only the individual grammars required by an application.
This is free and open source software.
Key Features
- Offers syntax highlighting similar to GitHub’s PrettyLights system.
- Supports more than 600 TextMate grammars.
- Provides a smaller collection of around 35 commonly used grammars.
- Lets developers load and register individual grammars dynamically.
- Returns highlighted code as a hast abstract syntax tree.
- Recognises languages from names, file extensions and file paths.
- Works in Node.js, Deno and modern web browsers.
- Integrates with React, Preact, Solid, Svelte, Vue, unified, rehype and markdown-it workflows.
- Includes light, dark, colour-blind, high-contrast, dimmed and tritanopia CSS themes.
- Supports automatic theme switching based on the system colour scheme.
- Uses CSS classes rather than inline styles, simplifying custom themes.
- Can identify missing grammar dependencies.
- Distributed as an ESM-only JavaScript package with TypeScript declarations.
Website: github.com/wooorm/starry-night
Support:
Developer: Titus Wormer
License: MIT License
starry-night is written in JavaScript. Learn JavaScript with our recommended free books and free tutorials.
Related Software
| Syntax Highlighters | |
|---|---|
| Prism | Lightweight, extensible syntax highlighter, with modern web standards in mind |
| Re-Highlight | Powerful syntax highlighter |
| Chroma | General purpose syntax highlighter |
| Pygments | Generic syntax highlighter |
| Rouge | Pure Ruby syntax highlighter |
| Highlight.js | JavaScript syntax highlighter with language auto-detection |
Read our verdict in the software roundup.
Explore our comprehensive directory of recommended free and open source software. Our carefully curated collection spans every major software category.This directory is part of our ongoing series of informative articles for Linux enthusiasts. It features hundreds of detailed reviews, along with open source alternatives to proprietary solutions from major corporations such as Google, Microsoft, Apple, Adobe, IBM, Cisco, Oracle, and Autodesk. You’ll also find interesting projects to try, hardware coverage, free programming books and tutorials, and much more. Discovered a useful open source Linux program that we haven’t covered yet? Let us know by completing this form. |


Please read our Comment Policy before commenting.