html2text is a Python library that efficiently converts HTML into clean, easy-to-read plain ASCII text, which is also valid Markdown. It provides extensive customization options for the conversion process. The library maintains an active and healthy development status with regular releases, ensuring ongoing support and feature enhancements.
pip install html2textVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates both the simple `html2text()` function for basic conversion and the `HTML2Text` class for more granular control over the output, such as ignoring links or disabling line wrapping.
Upgrade your Python environment to 3.9 or newer.
Fetch HTML content using a dedicated HTTP client (e.g., `requests`) and pass the HTML string to `html2text.html2text()` or `HTML2Text().handle()`.
Use `h = html2text.HTML2Text(); h.option = True; h.handle(html)` for custom configurations.
When using `HTML2Text()`, set `h.body_width = 0` to prevent line wrapping.
No dependency data recorded yet.