Skip to main content
The highlight command runs syntax highlighting on an arbitrary file. It can output colors directly to your terminal using ANSI escape codes, or produce HTML.
Aliases: hi For more information about syntax highlighting, see Syntax Highlighting.

Input Sources

File Paths

Pass file paths directly:

Paths File

Use --paths to provide a file containing paths:

Standard Input

If no paths are provided, input is read from stdin:

Output Formats

Terminal (ANSI)

By default, outputs colored text to the terminal:

HTML

Generate an HTML document with syntax highlighting:

HTML with CSS Classes

Generate HTML with CSS classes instead of inline styles:

Options

Output Options

flag
Output an HTML document with syntax highlighting.
flag
Output HTML with CSS classes instead of inline styles. Must be used with --html.
flag
Suppress main output.
flag
Print the time taken to highlight the file.

Validation Options

flag
Check that the highlighting captures conform strictly to the standards.
path
The path to a file with captures. These captures are considered the “standard” captures to compare against when using --check.

Query Options

paths
The paths to query files to use for syntax highlighting. These should end in highlights.scm. Can be specified multiple times.

Input Options

file
The path to a file that contains paths to source files to highlight.
path
The path to the directory containing the grammar. Implies --rebuild.
scope
The language scope to use for syntax highlighting. Useful when the language is ambiguous.
encoding
The encoding of the input files. One of utf8, utf16-le, utf16-be.
number
Highlight the contents of a specific test.

Build Options

flag
Force a rebuild of the parser before highlighting.
path
The path to an alternative configuration (config.json) file. See init-config.

Examples

Highlight to Terminal

Generate HTML

Generate HTML with CSS Classes

Highlight Multiple Files

Highlight with Custom Query

Check Highlight Conformance

Highlight with Performance Measurement

Theme Configuration

Colors are controlled by the theme in your config file. See init-config for information on configuring the theme.