Inscriptis
Python HTML-to-text converter that preserves layout, nested tables, and structure
Repository Health
Technical Analysis
Inscriptis is a Python library for converting HTML documents into clean, readable plain text. Unlike naive tag strippers, it renders HTML the way a browser would lay it out, preserving the visual structure of the page including indentation, lists, and even complex nested tables, so the resulting text stays faithful to the original document.
Beyond the core library, Inscriptis ships a command-line client and a web service, and it supports text annotations that map extracted text back to HTML attributes and tags. This makes it a strong choice for text extraction, web scraping, and natural-language-processing pipelines where accurate, well-formatted plain text matters.
What You Get
- A get_text() function that converts HTML into layout-preserving plain text
- Accurate rendering of nested tables, lists, and indentation
- A command-line client for converting HTML files or URLs to text
- An optional web service and an annotation API that links text back to HTML tags
Common Use Cases
- Extracting readable article text from web pages for NLP or search indexing
- Converting HTML emails or documents into clean plain text
- Scraping content where table and layout fidelity matters
- Producing annotated text that retains references to the source HTML structure
Under The Hood
Architecture - The core lives in src/inscriptis/: html_engine.py drives a browser-like rendering pass that walks the parsed HTML tree applying display semantics, html_properties.py and css_profiles.py encode the CSS-like layout rules (display, whitespace, margins, alignment) that produce faithful spacing and table formatting, model/ holds the intermediate canvas/table representation, annotation/ implements the tag-to-text annotation engine, and cli/ and service/ provide the command-line client and web service wrappers around the same engine. Tech Stack - Pure Python built on lxml for HTML parsing, packaged with modern pyproject tooling and distributed on PyPI, with optional extras for the annotation and web-service components. Code Quality - A mature, actively maintained project with clear module separation, a documented test suite, and readable, well-typed code; the layout-engine design reflects deliberate architecture rather than ad-hoc string manipulation. API Design - The primary API is a single get_text(html, config) call returning formatted text, with a parallel annotation API and configurable CSS profiles for tuning output; thorough ReadTheDocs documentation and a CLI make it easy to adopt.