Syntax highlighting for your terminal πŸ’»βœ¨
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin Fix bin link Aug 15, 2016
src fix(cli): correct usage of yargs version option Nov 30, 2017
.editorconfig ci(release): use semantic-release Nov 22, 2017
.gitignore chore(node): drop support for node 4 May 1, 2018
.prettierignore chore(node): drop support for node 4 May 1, 2018
.travis.yml ci(travis): only build master May 7, 2018
LICENSE.txt Add LICENSE Aug 13, 2016 docs(readme): highlight new complete language support Nov 25, 2017
package-lock.json chore(deps): update dependency @types/jest to v22 (#40) May 7, 2018
package.json chore(deps): update dependency @types/jest to v22 (#40) May 7, 2018
prettier.config.js style: use prettier Nov 23, 2017
renovate.json chore: Configure Renovate (#39) May 7, 2018
tsconfig.json chore(package): update dependencies May 1, 2018
tslint.json style: use prettier Nov 23, 2017


Syntax highlighting in your terminal

npm downloads build codecov dependencies node code style: prettier semantic-release license


Example Test Output

CLI Usage

Output a file

$ highlight package.json

Color output of another program with piping. Example: A database migration script that logs SQL Queries

$ db-migrate --dry-run | highlight

Command line options:

Usage: highlight [options] [file]

Outputs a file or STDIN input with syntax highlighting

  --language, -l  Set the langugage explicitely
                  If omitted will try to auto-detect
  --theme, -t     Use a theme defined in a JSON file
  --version, -v   Show version number                                   [boolean]
  --help, -h      Show help                                             [boolean]

Programmatic Usage

You can use this module programmatically to highlight logs of your Node app. Example:

const highlight = require('cli-highlight').highlight
const Sequelize = require('sequelize')

const db = new Sequelize(process.env.DB, {
  logging(log) {
    console.log(highlight(log, {language: 'sql', ignoreIllegals: true}))

Detailed API documenation can be found here.


You can write your own theme in a JSON file and pass it with --theme. The key must be one of the highlight.js CSS class names and the value must be one or an array of Chalk styles to be applied to that token.

  "keyword": "blue",
  "built_in": ["cyan", "dim"],
  "string": "red"

The theme is combined with the default theme. The default theme is still not colored a lot or optimized for many languages, PRs welcome!

Supported Languages

All languages of highlight.js are supported. Check a CI build for examples of all the different languages and their highlighting.


The module is written in TypeScript and can be compiled with npm run build. npm run watch starts tsc in watch mode. Tests are written with mocha.

Improving language support is done by adding more colors to the tokens in the default theme and writing more tests.