[![good first issue](https://badgen.net/github/label-issues/highlightjs/highlight.js/good%20first%20issue/open)](https://github.com/highlightjs/highlight.js/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)
<!-- [![commits since release](https://img.shields.io/github/commits-since/highlightjs/highlight.js/latest?label=commits+since)](https://github.com/highlightjs/highlight.js/commits/main) -->
- [Download from our website](#download-from-our-website)
- [Install via NPM package](#install-via-npm-package)
- [Build from Source](#build-from-source)
- [Requirements](#requirements)
- [License](#license)
- [Links](#links)
---
#### Upgrading to Version 11
As always, major releases do contain breaking changes which may require action from users. Please read [VERSION_11_UPGRADE.md](https://github.com/highlightjs/highlight.js/blob/main/VERSION_11_UPGRADE.md) for a detailed summary of breaking changes and any actions you may need to take.
#### Support for older versions <!-- omit in toc -->
Please see [SECURITY.md](https://github.com/highlightjs/highlight.js/blob/main/SECURITY.md) for long-term support information.
---
## Basic Usage
### In the Browser
The bare minimum for using highlight.js on a web page is linking to the
library along with one of the themes and calling [`highlightAll`][1]:
To skip highlighting of a code block completely, use the `nohighlight` class:
```html
<pre><codeclass="nohighlight">...</code></pre>
```
### Node.js on the Server
The bare minimum to auto-detect the language and highlight some code.
```js
// load the library and ALL languages
hljs = require('highlight.js');
html = hljs.highlightAuto('<h1>Hello World!</h1>').value
```
To load only a "common" subset of popular languages:
```js
hljs = require('highlight.js/lib/common');
```
To highlight code with a specific language, use `highlight`:
```js
html = hljs.highlight('<h1>Hello World!</h1>', {language: 'xml'}).value
```
See [Importing the Library](#importing-the-library) for more examples of `require` vs `import` usage, etc. For more information about the result object returned by `highlight` or `highlightAuto` refer to the [api docs](https://highlightjs.readthedocs.io/en/latest/api.html).
## Supported Languages
Highlight.js supports over 180 languages in the core library. There are also 3rd party
language definitions available to support even more languages. You can find the full list of supported languages in [SUPPORTED_LANGUAGES.md][9].
## Custom Usage
If you need a bit more control over the initialization of
Highlight.js, you can use the [`highlightElement`][3] and [`configure`][4]
functions. This allows you to better control *what* to highlight and *when*.
For example, here’s the rough equivalent of calling [`highlightAll`][1] but doing the work manually instead:
import hljs from 'https://unpkg.com/@highlightjs/cdn-assets@11.7.0/es/highlight.min.js';
// and it's easy to individually load & register additional languages
import go from 'https://unpkg.com/@highlightjs/cdn-assets@11.7.0/es/languages/go.min.js';
hljs.registerLanguage('go', go);
</script>
```
**Note:** *The CDN-hosted `highlight.min.js` package doesn't bundle every language.* It would be
very large. You can find our list of "common" languages that we bundle by default on our [download page][5].
#### Download prebuilt CDN assets
You can also download and self-host the same assets we serve up via our own CDNs. We publish those builds to the [cdn-release](https://github.com/highlightjs/cdn-release) GitHub repository. You can easily pull individual files off the CDN endpoints with `curl`, etc; if say you only needed `highlight.min.js` and a single CSS file.
There is also an npm package [@highlightjs/cdn-assets](https://www.npmjs.com/package/@highlightjs/cdn-assets) if pulling the assets in via `npm` or `yarn` would be easier for your build process.
### Download from our website
The [download page][5] can quickly generate a custom single-file minified bundle including only the languages you desire.
**Note:** [Building from source](#build-from-source) can produce slightly smaller builds than the website download.
### Install via NPM package
Our NPM package including all supported languages can be installed with NPM or Yarn:
```bash
npm install highlight.js
# or
yarn add highlight.js
```
Alternatively, you can build the NPM package from source.
### Build from Source
The [current source code][10] is always available on GitHub.
```bash
node tools/build.js -t node
node tools/build.js -t browser :common
node tools/build.js -t cdn :common
```
See our [building documentation][6] for more information.
## Requirements
Highlight.js works on all modern browsers and currently supported Node.js versions. You'll need the following software to contribute to the core library:
- Node.js >= 12.x
- npm >= 6.x
## License
Highlight.js is released under the BSD License. See our [LICENSE][7] file
for details.
## Links
The official website for the library is <https://highlightjs.org/>.
Further in-depth documentation for the API and other topics is at
<http://highlightjs.readthedocs.io/>.
A list of the Core Team and contributors can be found in the [CONTRIBUTORS.md][8] file.