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 |
| Highlight.js | JavaScript syntax highlighter with language auto-detection |
| Shiki | Themeable code rendering powered by TextMate grammars |
| Chroma | General purpose syntax highlighter |
| Rouge | Pure Ruby syntax highlighter |
| Pygments | Generic syntax highlighter |
| starry-night | GitHub-style code colouring for JavaScript projects |
| Highlight | Transforms source code into polished, readable output |
| Re-Highlight | Powerful syntax highlighter |
Read our verdict in the software roundup.
LinuxLinks helps you discover the best free and open source software for Linux. Explore our extensive collection of recommended applications, including alternatives to popular proprietary software.We also publish software reviews, Linux tutorials, hardware reviews, free programming books and articles covering the wider open source community. Browse our Linux resources to discover more. Know a useful free and open source Linux application we haven't covered? Suggest a program for inclusion. Has your software been featured on LinuxLinks? Display one of our Featured on LinuxLinks badges on your website or GitHub README. |


Please read our Comment Policy before commenting.