html2text
Turn HTML into equivalent Markdown-structured text.
What it is and what it does
html2text is a command-line tool and Python library that transforms HTML into plain ASCII text formatted as valid Markdown. It strips HTML markup while preserving document structure—bold, italic, links, code blocks, and other semantic elements are converted to their Markdown equivalents. The tool offers fine-grained control over output through options like link handling (ignore, reference-style, or inline), special character escaping, and code block marking.
The package has zero runtime dependencies and works as both a standalone script (invoked with `html2text [filename]`) and as an importable Python module. It supports modern Python versions (3.9 through 3.13) on CPython and PyPy, making it suitable for integration into text processing pipelines, documentation generators, or any workflow that needs to extract readable content from HTML.
Use it for:
- Extract readable text from web pages or HTML emails for archival or plain-text distribution.
- Convert HTML documentation to Markdown for version control and static site generators.
- Batch-process HTML files into text format for downstream NLP or text analysis tasks.
- Generate reference-style Markdown from HTML with customizable link formatting.
- Strip HTML markup while preserving semantic structure for accessibility or readability tools.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Converts HTML to clean, readable plain text or Markdown-formatted output, with options to customize link handling, escaping, and code block marking.
Yes, if you need HTML-to-text or HTML-to-Markdown conversion without external dependencies. The package is stable, widely used (top 5000 on PyPI), and has no known vulnerabilities. The aging maintenance status (last release 486 days ago) is a minor concern for new feature requests but does not block routine use. Avoid if you require active, frequent updates or have strict copyleft license restrictions in your project.
Install
html2text on PyPI
pip
pip install html2textuv
uv add html2textpoetry
poetry add html2textInstalling html2text
Before you install
Low install friction with no runtime dependencies. Maintenance status is aging—last release was 486 days ago—but the repository remains active and the package is marked Production/Stable with broad Python version support (3.9–3.13).
License in practice
Licensed under GPL-3.0-or-later (copyleft). Any software that incorporates or distributes this package must also be released under a compatible copyleft license; proprietary or closed-source projects cannot use it without legal review.
Quickstart
pip install html2text
import html2text
h = html2text.HTML2Text()
h.ignore_links = False
print(h.handle("<p>Hello, <b>world</b>!</p>"))
Requires Python 3.9 or later.
Verify before relying
- Whether the aging maintenance status (486 days since last release) affects bug fixes or compatibility with newer Python minor versions beyond 3.13.
- Performance characteristics on large HTML documents or batch conversion workloads.
Package facts
| License | GPL-3.0-or-later (copyleft) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 486 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 15,159,925/month — #1,197 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: html2text-2025.4.15-py3-none-any.whl
Tags
More HTML packages
MarkupSafe provides a text object that escapes…
permissive · top 100 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
beautifulsoup4Beautiful Soup parses HTML and XML documents…
permissive · top 100 on PyPI
lxmllxml provides Python bindings to libxml2 and…
permissive · top 1,000 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
MarkdownConverts Markdown text to HTML using a Python…
permissive · top 1,000 on PyPI
markdown2Converts Markdown text to HTML using a fast,…
permissive · top 5,000 on PyPI
strip-markdownConverts markdown text to plain text, removing…
permissive · top 15,000 on PyPI
mdit-plainConverts markdown documents to plain text by…
permissive · top 15,000 on PyPI
jusTextjusText removes boilerplate content…
permissive · top 5,000 on PyPI
junit2htmlConverts JUnit or XUnit XML test result files…
permissive · top 5,000 on PyPI
mistuneMistune converts Markdown text to HTML using a…
permissive · top 1,000 on PyPI
ansi2txtConverts ANSI escape sequences (color codes,…
unclear · top 15,000 on PyPI
telegramify-markdownConverts Markdown to Telegram plain text with…
permissive · top 15,000 on PyPI
readme-rendererSafely renders README files in Markdown,…
permissive · top 1,000 on PyPI