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
- Type or paste into the "Code" box, or press "Use example" to try it with sample data.
- Set "Language" if the defaults do not fit.
- The result appears below and updates as you type.
- 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 .