Chroma is a general-purpose syntax highlighting library and corresponding command, for Go.


Highlight source code from a file with the Python lexer and output to stdout

$ chroma --lexer [python] [path/to/]

Highlight source code from a file with the Go lexer and output to an HTML file
$ chroma --lexer [go] --formatter [html] [path/to/source_file.go] > [path/to/target_file.html]

Highlight source code from stdin with the C++ lexer and output to an SVG file, using the Monokai style
$ [command] | chroma --lexer [c++] --formatter [svg] --style [monokai] > [path/to/target_file.svg]

List available lexers, styles and formatters
$ chroma --list


chroma [options] files ...


This manual page documents briefly the chroma command.


These programs follow the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options is included below.


Show context-sensitive help.


List lexers, styles and formatters.


Do not buffer output.


Trace lexer states as they are traversed.


Do not format, check for tokenization errors instead.


Filename to use for selecting a lexer when reading from stdin.

-l, –lexer=autodetect

Lexer to use when formatting.

-s, –style=swapoff

Style to use for formatting.

-f, –formatter=terminal

Formatter to use.


Enable HTML mode (equivalent to `–formatter html').


HTML CSS class prefix.


Output HTML CSS styles.


Output HTML fragment.


Output HTML with inline styles (no classes).


Set the HTML tab width.


Include line numbers in output.


Split line numbers and code in a HTML table


Style for line numbers.


Highlight these lines.


Style used for highlighting lines.


Base line number.


Show application version.


See GitHub Issues: <>

Copied to clipboard