---
id: ansi2html
version: "1.9.2"
license: LGPLv3+
license_treatment: copyleft
maintenance: active
---
# ansi2html — Convert text with ANSI color codes to HTML or to LaTeX
License: copyleft · Maintenance: active · Downloads: 2.3M/mo
## What it is and what it does
ansi2html is a utility for converting terminal text containing ANSI color and formatting codes into HTML or LaTeX markup. It works both as a Python library (via the Ansi2HTMLConverter class) and as a command-line tool, making it useful for capturing colored terminal output and rendering it in web pages or documents. The package depends on importlib-metadata and typing-extensions, both lightweight standard-library backports.
Typical use cases include converting colored log output to HTML for web display, converting task runner output to shareable HTML, or piping colored command output through the tool to preserve formatting. It has been actively maintained since its first release in 2010, supports Python 3.7 through 3.12, and carries no known security vulnerabilities.
Use it for:
- Convert colored log files to HTML for web-based log viewing and archival
- Pipe colored CLI tool output through ansi2html to create shareable HTML reports
- Preserve terminal colors when exporting test runner or build tool output to HTML
- Convert colored task management or monitoring tool output to LaTeX for documentation
- Generate HTML versions of colored terminal sessions for documentation or tutorials
## Worth the install?
AI-flagged interpretation of the facts above — verify before relying.
Converts terminal output with ANSI color codes to HTML or LaTeX, preserving colors and formatting for display in browsers or documents.
Yes. ansi2html is a stable, actively maintained utility with no known vulnerabilities, low install friction, and a clear single purpose. The copyleft LGPLv3+ license is appropriate for open-source projects and most internal use; proprietary projects should verify compatibility. Install it if you need to convert ANSI-colored terminal output to HTML or LaTeX.
## Install
pip install ansi2html
uv add ansi2html
poetry add ansi2html
## Installing ansi2html
Before you install: Low friction install with minimal dependencies. Active maintenance with recent commits as of 2026-08-03 and stable production status.
License in practice: Licensed under LGPLv3+, a copyleft license requiring derivative works to remain open-source under the same terms. Suitable for open-source projects; proprietary use requires careful review.
Quickstart:
pip install ansi2html
from ansi2html import Ansi2HTMLConverter
conv = Ansi2HTMLConverter()
html = conv.convert(ansi_text)
Verify before relying:
- Whether LaTeX output preserves all ANSI color codes or only a subset
- Performance characteristics with very large ANSI-colored outputs
- Specific ANSI codes or color ranges supported by the converter
## Package facts
- License: LGPLv3+ (copyleft)
- Python support: supports_current
- Install friction: low
- Maintenance: active
- Downloads: 2.3M/month (top 5,000 on PyPI)
- Known vulnerabilities: none known
## Tags
ansi color codes to html, terminal output html conversion, ansi escape sequences html, colored text html export, ansi to latex converter, terminal colors to markup, terminal-output, color-conversion
[View on SkillFed](https://skillfed.io/packages/ansi2html) · [View on PyPI](https://pypi.org/project/ansi2html/)