Skip to main content

Trafilatura and its forks & ports

Trafilatura is an open-source Python library and command-line tool for gathering text from the web. It extracts main text, comments, and metadata from HTML, with tools for discovering URLs, downloading pages, and exporting the results.1

An HTML page is bigger than its article. Navigation menus, recommendations, advertisements, and footers can accompany the text a reader came for. In a research corpus, repeating those elements across thousands of documents introduces material that belongs to the website's template rather than the individual text being studied.2 Stripping tags isn't enough.

Trafilatura tries to separate that main content from the surrounding boilerplate, while retaining useful structure such as paragraphs, headings, lists, and quotations. Its name comes from the Italian word for wire drawing — a fitting image for refining raw material into something usable.1

Origins and history

Adrien Barbaresi started the work during a PhD at the intersection of linguistics and natural language processing. It was initially developed to build research text databases at the Berlin-Brandenburg Academy of Sciences, including work for its DWDS and ZDL units.3

The project grew out of earlier research on extracting news and blog articles. Barbaresi's 2021 ACL-IJCNLP system-demonstration paper presented Trafilatura as a reusable library and command-line tool, described its extraction process, and evaluated it on a collection of web documents; a lexicographic research platform needed usable text, and getting a download was only the beginning.2

I find that origin helpful: the project treats extraction as a decision about which text belongs in a corpus.

The original Python project now combines extraction with discovery, downloading, crawling, and output conversion. Its licensing also changed over time: version 1.8.0 moved to Apache-2.0; earlier releases used GPLv3+.14

How extraction works

Trafilatura works with an HTML tree parsed by lxml, or accepts one that the caller has already parsed. Its main extractor applies rules to the document's structure rather than requiring a custom scraper for each website.56

First, it removes or simplifies unwanted elements and searches for likely content containers. An <article> element, itemprop="articleBody", and familiar IDs or classes such as entry-content provide clues. These are candidates, not guarantees: the extractor also prunes unwanted sections and tests link density, which helps distinguish a block of prose from a cluster of navigation links.6

Element handlers then collect paragraphs, lists, quotations, and tables while preserving supported structure. If the first pass captures too little, internal recovery looks more widely for text it missed. Other recovery stages can use a broader baseline or retry with more permissive recall settings, depending on the selected mode.78

Outside fast=True, Python Trafilatura can also compare its result with bundled readability-lxml and conditionally try jusText. Fast mode skips those external comparisons; it still has internal recovery. That distinction matters when describing the descendants below.98

Metadata extraction runs separately, reading titles, authors, dates, and other page information. Finally, the result is serialized: plain text is the default, with Markdown, HTML, JSON, CSV, XML, and XML-TEI available. The selected format determines how much of the extracted structure reaches the caller.75

Forks and ports

A port reimplements software in another language; a fork develops inherited code in a separate project. Two related projects bring Trafilatura's extraction approach into other environments.

go-trafilatura, created by Markus Mobius, is a Go port. It extracts main text, comments, and metadata from supplied HTML. Its separate command-line tool can also fetch pages and process URL lists, feeds, and sitemaps.10

Trafilatura Core is an open-source extraction engine based on Trafilatura, implemented in TypeScript and native Python. Its TypeScript engine directly ports Python Trafilatura v2.2.0's fast=True path; go-trafilatura supplied only a DOM translation aid. Core's maintained native Python implementation translates that TypeScript engine. Both accept supplied HTML and return cleaned HTML with metadata and diagnostics, without fetching or rendering pages.1112

Lineage diagram showing Python Trafilatura as the source of go-trafilatura and its fast path as the source of Trafilatura Core, with Go serving Core only as a DOM translation aid

Python Trafilatura is the source of the Go port and Core's TypeScript extraction engine. The dashed Go-to-Core relationship is only a DOM translation aid; Core's native Python implementation translates its TypeScript engine.1011

For the extraction algorithms and recovery boundaries of Mozilla Readability, Python Trafilatura, and Core, see Trafilatura Core vs Mozilla Readability: how extraction works.

Citations

  1. Trafilatura: Project description, features, name, and license. Retrieved October 7, 2026 ↩ ↩2 ↩3

  2. Adrien Barbaresi: Trafilatura: A Web Scraping Library and Command-Line Tool for Text Discovery and Extraction. ACL-IJCNLP System Demonstrations, 2021 ↩ ↩2

  3. Adrien Barbaresi: Trafilatura project history. Retrieved October 7, 2026 ↩

  4. Trafilatura: v1.8.0 license change. Retrieved October 7, 2026 ↩

  5. Trafilatura: Python inputs and output formats. Retrieved October 7, 2026 ↩ ↩2

  6. Adrien Barbaresi: Trafilatura 2.3.0 content selectors and main extraction and recovery. Retrieved October 7, 2026 ↩ ↩2

  7. Trafilatura: How extraction works. Retrieved October 7, 2026 ↩ ↩2

  8. Adrien Barbaresi: Trafilatura 2.3.0 extraction pipeline. Retrieved October 7, 2026 ↩ ↩2

  9. Adrien Barbaresi: Trafilatura 2.3.0 external extractor comparisons. Retrieved October 7, 2026 ↩

  10. go-trafilatura: Go port, authorship, extraction scope, and CLI. Retrieved October 7, 2026 ↩ ↩2

  11. Trafilatura Core: Source lineage and native Python translation and fast-path extraction source. Retrieved October 7, 2026 ↩ ↩2

  12. Trafilatura Core: Product scope and native Python library. Retrieved October 7, 2026 ↩

Updated: October 7, 2026