Media and documents · Library

highlight.js

A JavaScript library that colours code snippets on web pages according to their programming language, the way a code editor does.

Writing formats · Open source · updated

How it works

highlight.js turns the text inside pre and code blocks into spans with classes such as hljs-keyword and hljs-string, which a theme stylesheet then colours. It ships grammars for nearly 200 languages and a wide choice of themes, can guess the language when none is given, and runs in the browser, in Node or in a build step. Importing only the languages you need keeps the bundle small.

It only highlights: line numbers, copy buttons and editing come from plugins or your own code. Prism is a similar lightweight option, and Shiki uses the same grammars as VS Code for more accurate colours, usually at build time. For editable code, an editor such as CodeMirror or Monaco is the right tool.

highlight.js pricing

Open source

Free (BSD 3-Clause).

Approximate, checked September 2026.What the other tools cost

More in Media and documents

Writing formats

All 14 Media and documents terms

Crafted in the dark. Shipped to the world.

Tell us what you are building. You get a private project space with a proposal and a line-by-line quote within a day.