--- id: html-text version: "0.7.1" license: MIT license_treatment: permissive maintenance: aging --- # html-text — Extract text from HTML License: permissive · Maintenance: aging · Downloads: 1.4M/mo ## What it is and what it does html-text extracts readable text from HTML by removing invisible content (styles, scripts, comments) and normalizing whitespace in a way that mimics how a browser renders the page. Unlike simple XPath or Beautiful Soup text extraction, it adds intelligent spacing around inline elements and can insert newlines after headers and paragraphs to preserve document structure in the output. The package provides multiple entry points: a high-level extract_text() function for raw HTML strings, lower-level etree_to_text() for pre-parsed lxml trees, and integration with parsel.Selector for targeted extraction from specific elements. It's designed for both display purposes and machine learning feature extraction, where clean, normalized text is needed as input to classification pipelines. Use it for: - Extract readable text from web pages for search indexing or content aggregation - Prepare HTML content as features for text classification or NLP models - Convert web scraping results to plain text for downstream text processing - Remove boilerplate (styles, scripts) while preserving document structure via newlines - Build text-only versions of web content for accessibility or archival ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Extracts plain text from HTML while filtering out styles, scripts, comments, and normalizing whitespace intelligently to match browser rendering. Yes, if you need to extract clean text from HTML with structure preservation. Low install friction, permissive license, no known vulnerabilities, and stable API make it a safe choice. Maintenance is aging but the repository remains active; suitable for production use in text extraction pipelines. ## Install pip install html-text uv add html-text poetry add html-text ## Installing html-text Before you install: Low friction: pure Python wheel with only lxml and lxml-html-clean as runtime dependencies. Last release 312 days ago; repository is active and not archived, though maintenance status is aging. License in practice: MIT license is permissive; you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions. Quickstart: pip install html-text import html_text text = html_text.extract_text('

Hello

world

') print(text) Requires lxml, which has compiled C dependencies; installation may need a C compiler or pre-built wheels for your platform. Verify before relying: - Whether parsel is an optional dependency or required for selector_to_text functionality - Performance characteristics on large HTML documents or batch processing scenarios ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: aging - Downloads: 1.4M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags extract text from html, html to plain text, remove html tags, clean html content, text extraction from web pages, html parsing and text extraction, convert html to text, web-scraping, text-extraction, nlp-preprocessing [View on SkillFed](https://skillfed.io/packages/html-text) · [View on PyPI](https://pypi.org/project/html-text/)