skillfed

ansi2html

Convert text with ANSI color codes to HTML or to LaTeX

ansi2html v1.9.2 2.3M downloads/30d#3,155 on PyPI423
Copyleft license LGPLv3+ Active released

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 on this page — 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

ansi2html on PyPI

pip

pip install ansi2html

uv

uv add ansi2html

poetry

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 the current Python release (>=3.7)
Install friction low — pure-Python wheel
Runtime dependencies 2 — importlib-metadata, typing-extensions
Maintenance actively maintained — 783 days since the last release
Last repo commit
First released
Downloads 2,302,559/month — #3,155 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: ansi2html-1.9.2-py3-none-any.whl

Keywords: ansi, html, color

Development Status :: 5 - Production/StableEnvironment :: ConsoleIntended Audience :: DevelopersIntended Audience :: System AdministratorsLicense :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)License :: OSI Approved :: MIT LicenseOperating System :: MacOSOperating System :: POSIXProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Quality AssuranceTopic :: Software Development :: TestingTopic :: System :: Systems AdministrationTopic :: Text ProcessingTopic :: Text Processing :: MarkupTopic :: Text Processing :: Markup :: HTMLTopic :: Utilities

Tags

ansi color codes to htmlterminal output html conversionansi escape sequences htmlcolored text html exportansi to latex converterterminal colors to markup
terminal-outputcolor-conversion

More Utilities packages