Handitab

Syntax Highlighter

Add syntax highlighting to code in 30+ languages, preview the colored result, and copy it as HTML with class names for your own page.

About Syntax Highlighter

Syntax highlighting colors source code by the role of each token, such as keywords, strings, numbers, and comments. This tool uses the highlight.js library (version 11.9), loaded from a CDN on first use, which can also guess the language from the code. The output is HTML in which each token is wrapped in a span with an hljs class name. To show colors on your own page, include a highlight.js theme stylesheet.

How to use Syntax Highlighter

  1. Type or paste into the "Code" box, or press "Use example" to try it with sample data.
  2. Set "Language" if the defaults do not fit.
  3. The result appears below and updates as you type.
  4. Copy the result with the copy button, or download it as a file where that is offered.

Questions about Syntax Highlighter

Why is the copied HTML not colored on my site?

The HTML only marks tokens with class names such as hljs-keyword. The colors come from a theme stylesheet. Add one of the highlight.js theme CSS files to your page, or write your own rules for those classes.

Runs in your browser. Page last updated .

More developer tools

All 41 developer tools