Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Go library and CLI that converts ANSI terminal output into styled HTML.
Terminal-to-HTML is a Go library and command-line tool that converts ANSI-encoded shell output into styled HTML, with a single terminal-to-html command and an optional HTTP server.
Terminal-to-HTML is a Go library and command-line tool from Buildkite that converts arbitrary shell output containing ANSI escape sequences into rendered HTML. It accepts terminal output via STDIN or HTTP POST and outputs HTML that can be styled with the provided terminal.css stylesheet and wrapped in a term-container class. The project is open source under the MIT License and has collected 719 stars on GitHub.
terminal-to-html command reads terminal output from STDIN and writes HTML to stdout; the -preview flag is demonstrated in the README with cat fixtures/pikachu.sh.raw | terminal-to-html -preview > out.html.terminal-to-html -http=:6060 starts a web server; curl --data-binary "@fixtures/pikachu.sh.raw" http://localhost:6060/terminal > out.html converts a POSTed body and returns HTML.inline=1 are rendered; preserveAspectRatio is not supported.1338 embeds images from a URL with width, height, and alt attributes; the image.sh helper generates this sequence.1339 renders hyperlinks with url and content; the link.sh helper is provided, and URLs containing semicolons can be quoted.go install works from github.com/buildkite/terminal-to-html/v3/cmd/terminal-to-html.Terminal-to-HTML is for developers and teams that need to show terminal sessions inside web pages. It is especially useful for build log viewers, CI/CD dashboards, and technical documentation that wants to preserve ANSI color codes in a browser-safe format.
.raw terminal capture through the CLI to produce a standalone HTML file with ANSI colors preserved./terminal to get back HTML for use in a web app.1339 escape code to turn URLs in terminal output into hyperlinks in the rendered HTML.1338 escape code to reference images from the web, with size and alt attributes, inside the terminal flow.The tool parses ANSI escape codes from the input stream and maps them to equivalent HTML styling. It can operate as a one-shot pipeline reading STDIN or as a persistent HTTP server that converts each POST request body. The README shows both usage modes, and custom escape codes extend iTerm2's inline image format to support remote URLs and hyperlinks.
Yes, Terminal-to-HTML is open source under the MIT License. You can install it with go install github.com/buildkite/terminal-to-html/v3/cmd/terminal-to-html or download a standalone binary from the GitHub releases page.
No. The README explicitly warns that the tool is not hardened against cross-site scripting (XSS) or other attacks. If you run it on user-generated content, pass the HTML output through a sanitizer before displaying it in a browser.
Escape code 1338 embeds URL-based images with width, height, and alt attributes, while 1339 renders hyperlinks. Helper scripts image.sh and link.sh generate these sequences. URLs with semicolons can be surrounded by single or double quotation marks.
If you have Go installed, run go install github.com/buildkite/terminal-to-html/v3/cmd/terminal-to-html to install the command into $GOPATH/bin. Alternatively, download the standalone binary for your platform from the GitHub releases page.
