term2html
April 3, 2026 · View on GitHub
A terminal output (ANSI) → HTML converter that respects your terminal color palette.

input | term2html > output.html
The difference between this and tools such as ansi-to-html, aha and ansi2html is that this tool actually recreates the palette and dimensions of the user's terminal emulator window, so the output will look exactly the same as it does in the terminal.
Under the hood, this project uses ghostty-vt's parser and (a modified version of its) formatter, which means that it supports all of the features of a modern terminal emulator, including 24-bit color, true color, and all of the various text attributes (bold, italic, underline, etc) as well as hyperlinks.
Installation
Supported platforms are Linux, macOS and Windows (via WSL).
Download the latest release from the releases page and add the binary to your PATH.
You can also build the project from source using Zig, see the build instructions below.
Usage
Pipe the output of any command into term2html.
ls -l --color=always | term2html > ls.html
Many programs will not output color codes when they detect that their output is not a terminal, so you may need to force color output. For example, with ls you can use the --color=always flag. Consult the man pages or --help output of the program you're using for more information.
Tip
Instead of piping the output directly into term2html, you can write the command output to a file such as output.ansi, and then debug the ANSI escape sequences in a text editor. You can then input that ansi file into term2html like this: cat output.ansi | term2html > output.html.
Capturing interactive terminal sessions
While most programs have an option to force color output, some programs are interactive and communicate with the terminal via /dev/tty instead of stdout, so you can't just pipe their output into term2html. In this case, you need to use a terminal session recorder to capture the output of the program and then feed that into term2html.
To capture a program such as nvim, the easiest way is to use tmux:
> tmux
# Inside tmux, start the program and get it to the state you want to capture.
> nvim
# Then, in another terminal window, run the following command:
> tmux capture-pane -e -p | term2html > snapshot.html
# And voilà, show off your Neovim config with screenshots rendered in glorious HTML5!
Flags
--font "<font>": Set the font family for the output HTML. The default ismonospace.--default-theme: Use Ghostty's default color palette.
Build
- Install Zig version 0.15.2.
- Clone this repository and navigate to the project directory.
- Run the following command to build the project in release mode:
zig build --release=fast
The binary is produced at ./zig-out/bin/term2html.
Some platforms may not support SIMD, in which case you can build without SIMD support using the following command:
zig build --release=fast -Dsimd=false