Chroma is a general purpose syntax highlighter in pure Go that converts source code and structured text into syntax highlighted HTML, ANSI-coloured text, and other formats.
The tool addresses the need to transform raw source code into visually distinguished output by tokenizing input text and applying formatting rules. It works by identifying language-specific syntax patterns through lexers, then applying styles to produce formatted output. Chroma is based heavily on Pygments and includes translators for Pygments lexers and styles, allowing it to leverage an existing ecosystem of language definitions and color schemes.
Developers should choose Chroma when they need syntax highlighting as a library within Go applications or as a command-line tool. It suits projects that require flexible output formats beyond simple HTML, such as ANSI terminal coloring. The tool is particularly valuable for documentation generators, code review systems, and terminal-based applications where Go's single-binary deployment model is advantageous. Since Chroma is based on Pygments, developers familiar with that tool will recognize its architecture and capabilities.
The project maintains active development with ongoing refinement of its core API. A major version upgrade is in progress that modernizes the iterator interface to use Go's built-in iteration primitives rather than a custom type, reflecting attention to language evolution and API ergonomics. The codebase includes testing infrastructure for lexers, indicating commitment to correctness across supported languages. The project acknowledges gaps relative to Pygments and documents these limitations, showing transparency about its scope.