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
Related terms
More in Media and documents
Writing formats