skillfed

html2text

Turn HTML into equivalent Markdown-structured text.

html2text v2025.4.15 15.2M downloads/30d#1,197 on PyPI2,168
Copyleft license GPL-3.0-or-later AGING released

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 html2text

uv

uv add html2text

poetry

poetry add html2text

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPy

Tags

html to markdown conversionhtml to plain textconvert html documentsextract text from htmlhtml markdown converterstrip html formattinghtml parser text extraction
html-parsingmarkdown-generationtext-extraction

More HTML packages