Javascript syntax highlighter – highlight.js

Looking for a Javascript syntax highlighter? A nice solution for the web is highlight.js!

Javascript syntax highlighter – highlight.js

Highlight.js is a syntax highlighter written in JavaScript. It works in the browser as well as on the server. It works with pretty much any markup, doesn’t depend on any framework, and has automatic language detection.

Javascript syntax highlighter
Javascript syntax highlighter


– available for node.js

– works with any markup

– compatible with any js framework

– 185 languages and 89 styles

– automatic language detection

– multi-language code highlighting


npm install highlight.js --save


import hljs from 'highlight.js/lib/highlight';
import javascript from 'highlight.js/lib/languages/javascript';
hljs.registerLanguage('javascript', javascript);
// ...

To set the syntax highlighting style, if your build tool processes CSS from your JavaScript entry point, you can import the stylesheet directly into your CommonJS-module:

import hljs from 'highlight.js/lib/highlight';
import 'highlight.js/styles/github.css';

License: BSD





See also

Medium.js – control of content editable

JavaScript algorithms implemented

JavaScript format input while typing – Cleave.js

A good jQuery text counter plugin