---
title: "From HTML to text: how AI extracts a page’s content"
url: https://www.devjpt.com/en/blog/how-ai-extracts-page-content/
site: "Jean-Philippe Thériault"
type: post
language: en
published: 2026-12-01T05:12:55+00:00
updated: 2026-12-01T19:27:19+00:00
author: "Jean-Philippe Thériault"
description: "How AI extracts a page's content: menus and footers removed, conversion to text or Markdown, length limits, and what the official documentation says."
translations:
  ca: https://www.devjpt.com/ca/blog/ia-extreure-contingut-pagina/
  es: https://www.devjpt.com/es/blog/ia-extraer-contenido-pagina/
  fr: https://www.devjpt.com/blog/ia-extraire-contenu-page/
agent:
  instructions: "This site offers a search endpoint for AI agents. Results are returned in Markdown."
  endpoint: "https://www.devjpt.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://www.devjpt.com/.well-known/agent-skills/lire-devjpt/SKILL.md"
---

# From HTML to text: how AI extracts a page’s content

*Updated December 1, 2026.*

Outside the companies that make them, nobody knows exactly how ChatGPT, Claude, Gemini or Perplexity turn your page into text: according to the public documentation consulted on November 30, 2026, they do not describe the inner workings of their consumer products. What is documented are their web reading tools for developers, the methods published by researchers, and open-source extractors.

These documents point the same way: the menu, the footer and the scripts are removed; the page is cut short, or only a useful excerpt is kept; images become their alternative text, a bare address, or disappear; headings and tables survive or not, depending on the tool.

## What AI companies publish about extracting pages

A web page is first of all HTML code: a text file in which tags mark what is a heading, a paragraph, a menu or an image. An AI has to pull the useful text out of it: this is called main content extraction, and the guide [How an AI sees your web page](https://www.devjpt.com/en/blog/how-ai-sees-your-web-page/) shows where it fits.

The official documents say little about it: neither the “web fetch” tool in Anthropic’s API (the service sold to developers) nor the web search feature of OpenAI’s API says how the HTML becomes text. So I stick to what is published, without extending it to ChatGPT or the Claude app.

## First extraction step: removing the menu, the footer and the ads

Extracting the main content means keeping the central text and setting aside the navigation, ads, banners, header and footer, even though researchers admit this “main content” has no clear-cut definition. The most cited open-source extractors follow public rules:

- **trafilatura** removes the `<script>`, `<style>`, `<nav>` (navigation) and `<footer>` tags.
- **jusText** treats a short block containing a link, or a block full of links, as almost always boilerplate, meaning text repeated from page to page, such as menus.
- **Readability**, the engine behind Firefox’s Reader View, discards elements whose class or ID (labels in the code) suggests a menu, a sidebar, an ad, a footer or a pop-up.
- **Firecrawl**, a commercial service, strips the navigation and the footer by default.

Nothing says that ChatGPT or Claude use these tools, but the logic is clear: according to jusText’s rule, a list of services made only of short links may be thrown out like a menu.

Hidden content can also disappear. Readability removes elements marked as hidden in the tag itself (for example the `hidden` attribute); so a closed tab is not always removed: it all depends on its code. In an October 2025 blog post, a Bing (Microsoft) product manager warns that AI systems may not render hidden content in tabs or expandable menus. The topic will get its own [article on content hidden from AI](https://www.devjpt.com/en/blog/content-hidden-from-ai/).

No extractor is perfect: a peer-reviewed study (Bevendorff et al., SIGIR 2023 conference) compared 14 of them on 3,985 pages, with uneven results. My takeaway is that a clear structure helps all these tools.

## Second extraction step: plain text, sometimes Markdown

Several tools (Jina Reader, Firecrawl, Perplexity’s Context API, html2text) also convert the extracted text to Markdown, a plain text format in which a heading starts with “#”.

The extractor only sees the HTML it receives. According to its documentation, Anthropic’s web fetch tool does not support websites rendered with JavaScript, the code that builds part of the page in the browser: see [JavaScript and AI: why your page can look empty](https://www.devjpt.com/en/blog/javascript-ai-empty-page/).

## What survives extraction: headings, tables, images and links

The trafilatura extractor keeps the text of headings, lists and tables by default, but not links or images. Keeping that text is not keeping the structure: researchers who propose their own HTML-based method (Tan et al., WWW 2025) note that reducing HTML to plain text loses much of that structure.

| Element of your page | What the documented tools do |
| --- | --- |
| Menu, footer, sidebar | Removed by default (trafilatura, jusText, Readability, Firecrawl) |
| Headings, paragraphs, lists | Kept by trafilatura; the structure is often lost when HTML is reduced to plain text |
| HTML table | Kept as a table, flattened into rows or excluded, depending on the tool and its settings |
| Image | Kept with its address, replaced by its alternative text, or removed, depending on the settings |
| Text written inside an image | Not text at all for an HTML extractor |
| Link | Kept with its address or reduced to its text, depending on the tool and its settings |

For tables, the form matters: a study covering only GPT-3.5 and GPT-4 (Sui et al., WSDM 2024 conference) showed that the way a table is presented to the model changed its results. A real HTML table at least has a chance of keeping its rows and columns; a price grid published as an image has no such guarantee.

For images, Microsoft’s post acknowledges that AI systems can sometimes read the text in an image, but often with less accuracy; it recommends alternative text (the alt attribute) or presenting the essential details in HTML. Your opening hours on a poster, or a restaurant menu in a photo, may therefore disappear (see the [article on images, PDFs and videos](https://www.devjpt.com/en/blog/ai-images-pdf-videos/)).

## A page cut short, or only an excerpt: the documented limits

Each limit below applies to one specific tool, according to its documentation consulted on November 30, 2026:

- **Anthropic (web fetch, API)**: the developer can set an approximate cap in tokens (the units of text a model counts); beyond it, the page is truncated. In recent versions, Claude can also filter the page with code to keep only what is relevant.
- **Claude Code**, Anthropic’s coding tool: for most pages, a separate model call reads the page and answers a question; Claude receives that answer, not the full text. Each call reads 100,000 characters, and you can ask it for the next part.
- **OpenAI (web search, Responses API)**: the context window, meaning all the text the model processes at once, is limited to 128,000 tokens, even when the model accepts more.
- **Google (URL context, Gemini API)**: at most 34 MB per address; the tool first checks a copy in an internal index, otherwise the live page.
- **Perplexity (API)**: search returns an excerpt chosen for the query, “not the full page”; the URL fetching tool splits the page into excerpts for the model and may truncate long pages.

Several of these tools may also read a stored copy of your page rather than the live version: by default, up to 15 minutes old in Claude Code and two days at Perplexity; Google and Anthropic’s API give no duration. Nothing says that ChatGPT or the Claude app do the same.

Indexing crawlers have their own limits too. According to Google, Googlebot crawls, for Google Search, the first 2 MB of a page (64 MB for a PDF), measured on the uncompressed file. This figure applies only to Google Search, and a small business page rarely has 2 MB of HTML: it’s a reference point. Common Crawl, a web archive widely used to train AI (see the [list of AI crawlers](https://www.devjpt.com/en/blog/ai-crawlers-list/)), truncates pages beyond 5 MiB (about 5 MB) since March 2025. Long pages will get their [own article](https://www.devjpt.com/en/blog/how-ai-reads-long-pages-research/).

## What training datasets keep from a page

Three peer-reviewed studies describe how English-language pages were prepared to train models:

- The teams behind C4 (Raffel et al., Google, 2020), RefinedWeb (Penedo et al., 2023) and FineWeb (Penedo et al., Hugging Face, 2024) found that Common Crawl’s plain text keeps too many menus; RefinedWeb and FineWeb redid the extraction with trafilatura.
- C4 kept only lines of at least 5 words ending in a terminal punctuation mark, discarded pages with fewer than 3 sentences, and kept only one copy of any repeated three-sentence passage.

These rules serve training, not live answers, but they give an idea: complete sentences survive better than fragments, and a paragraph repeated across 40 service pages looks like boilerplate to these methods.

## What this changes for a small business page

Google writes that no special optimization is required for its AI features, and reminds site owners to make important content available as text. These steps promise no place in an AI answer: they limit what gets lost.

- **Clear headings and real paragraphs.** According to Microsoft, AI assistants break a page into pieces, and headings (`<h2>`, `<h3>`) mark where one idea ends and another begins.
- **Important text as text.** Prices, opening hours, list of services: written in the page, with useful alternative text for each image.
- **Tables as real HTML tables** (`<table>`), not images.
- **Main content in the main area.** The `<main>` tag marks the dominant content of a page; trafilatura and Readability look for similar markers (`<article>` elements, classes or IDs containing “main” or “content”). In my opinion, it’s a reasonable precaution: no AI provider says it takes it into account.
- **Nothing essential only behind a script or in a hidden tab** (see [the article on JavaScript](https://www.devjpt.com/en/blog/javascript-ai-empty-page/)).
- **The essentials early in the page.** Several tools cut long pages: what comes first is therefore the most likely to be read.

## See what an extraction keeps from your page

Try the [free simulator](https://www.devjpt.com/en/tools/ai-page-view-simulator/). It reads your page like a crawler that doesn’t run JavaScript, and its text view shows roughly what a main content extraction keeps. It’s an approximation: it is not the real crawler of an AI company. If your site blocks crawlers, that question comes first: see [Can ChatGPT read my website?](https://www.devjpt.com/en/blog/can-chatgpt-read-my-website/)

> **Waitlist.** I’m building new tools to help website owners and creators stay in control when it comes to AI. [Get notified at launch.](https://www.devjpt.com/en/waitlist/?source=how-ai-extracts-page-content)

## Frequently asked questions

### Do ChatGPT, Claude and Gemini explain how they extract the text of a web page?

No, not for their consumer products, according to the public documentation consulted on November 30, 2026. OpenAI, Anthropic and Google mainly document the web reading tools in their developer APIs, and even those pages say little about how HTML becomes text. What is known about extraction comes mostly from open-source extractors and from methods published by researchers.

### Do the extraction tools used for AI keep a website’s menu and footer?

Publicly documented extractors such as trafilatura, jusText and Readability generally remove the menu, the footer, the scripts and the ads to keep only the main content. The Firecrawl service does the same by default. Whether ChatGPT or Claude use these tools is unknown, because their inner workings are not published.

### What happens to a price table when an AI tool extracts the text of a web page?

It depends on the tool and its settings: an HTML table can stay a table, be flattened into rows or be excluded. A table published as an image is not text for an HTML extractor. A study presented in 2024 (WSDM conference), covering only GPT-3.5 and GPT-4, also showed that the way a table is presented to the model changed its results.

### Can an AI read the text written inside an image on a website?

For an HTML extractor, text written inside an image is not text: the image becomes its alternative text (alt), a bare address, or disappears, depending on the tool. A Microsoft blog post published in October 2025 acknowledges that AI systems can sometimes read text in images, but that this often reduces accuracy. It recommends providing alternative text or presenting the essential details in HTML.

### Do AI web reading tools cut off pages that are too long?

Several document it. Anthropic’s web fetch tool truncates content beyond a cap set by the developer, Claude Code reads 100,000 characters per call, and Perplexity’s URL fetching tool may truncate long pages. For Google Search, Googlebot crawls the first 2 MB of an HTML page. Each limit applies to one specific tool, according to its documentation consulted on November 30, 2026.

### Is text hidden in tabs kept when an AI tool extracts a web page?

Not always. Readability, the engine behind Firefox’s Reader View, removes elements marked as hidden in the tag itself, and Microsoft warns that AI systems may not render hidden content in tabs or expandable menus. It all depends on how the tab is coded: it’s best not to put essential information only there.

### How can I see what an AI tool keeps from my web page?

The free simulator on devjpt.com reads the page like a crawler that doesn’t run JavaScript and shows roughly the text that a main content extraction keeps. It’s an approximation: it is not the real crawler of an AI company, and each tool extracts in its own way.

## Sources

Documents consulted on November 30, 2026.

- Anthropic, “[Web fetch tool](https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-fetch-tool)” (Claude Platform); “[Tools reference](https://code.claude.com/docs/en/tools-reference),” “WebFetch tool behavior” section (Claude Code).
- OpenAI, “[Web search](https://developers.openai.com/api/docs/guides/tools-web-search)” (API documentation).
- Google, “[URL context](https://aistudio.google.com/docs/url-context)” (Gemini API, Google AI Studio); Google Search Central, “[What Is Googlebot](https://developers.google.com/search/docs/crawling-indexing/googlebot)” and “[AI features and your website](https://developers.google.com/search/docs/appearance/ai-features).”
- Perplexity, “[Fetch URL Content](https://docs.perplexity.ai/docs/agent-api/tools/fetch-url-content),” “[How Search Works](https://docs.perplexity.ai/docs/search/overview)” and “[Formats and freshness](https://docs.perplexity.ai/docs/context/formats-and-freshness).”
- Krishna Madhavan (Microsoft Bing), “[Optimizing Your Content for Inclusion in AI Search Answers](https://about.ads.microsoft.com/en/blog/post/october-2025/optimizing-your-content-for-inclusion-in-ai-search-answers),” Microsoft Advertising Blog, October 8, 2025.
- Common Crawl, “[Content is truncated](https://commoncrawl.org/errata/content-is-truncated)” (erratum).
- Raffel et al., “[Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer](https://arxiv.org/abs/1910.10683),” Journal of Machine Learning Research, 2020 (preprint from October 2019; C4 dataset, section 2.2).
- Penedo et al., “[The RefinedWeb Dataset for Falcon LLM: Outperforming Curated Corpora with Web Data, and Web Data Only](https://arxiv.org/abs/2306.01116),” NeurIPS 2023, Datasets and Benchmarks.
- Penedo et al., “[The FineWeb Datasets: Decanting the Web for the Finest Text Data at Scale](https://arxiv.org/abs/2406.17557),” NeurIPS 2024, Datasets and Benchmarks.
- Bevendorff, Gupta, Kiesel and Stein, “[An Empirical Comparison of Web Content Extraction Algorithms](https://downloads.webis.de/publications/slides/bevendorff_2023b.pdf),” SIGIR 2023, July 2023 (authors’ slides; the paper itself could not be accessed).
- Adrien Barbaresi, trafilatura documentation: “[How extraction works](https://trafilatura.readthedocs.io/en/latest/extraction-overview.html)” and “[Python usage](https://trafilatura.readthedocs.io/en/latest/usage-python.html).”
- Mozilla, “[Readability](https://github.com/mozilla/readability)“: README and source code of Readability.js (GitHub, file last changed September 16, 2025).
- Mišo Belica, “[Description of the jusText boilerplate cleaning algorithm](https://github.com/miso-belica/jusText/blob/main/doc/algorithm.rst).”
- Alireza Savand and contributors, “[html2text](https://github.com/Alir3z4/html2text)“: README and [docs/usage.md](https://github.com/Alir3z4/html2text/blob/master/docs/usage.md).
- Jina AI, “[Reader](https://github.com/jina-ai/reader)” (README, GitHub).
- Firecrawl, “[Scrape](https://docs.firecrawl.dev/features/scrape)” and “[Advanced Scraping Guide](https://docs.firecrawl.dev/advanced-scraping-guide).”
- Tan et al., “[HtmlRAG: HTML is Better Than Plain Text for Modeling Retrieved Knowledge in RAG Systems](https://arxiv.org/abs/2411.02959),” WWW 2025.
- Sui et al., “[Table Meets LLM: Can Large Language Models Understand Structured Table Data? A Benchmark and Empirical Study](https://arxiv.org/abs/2305.13062),” WSDM 2024.
- MDN Web Docs (Mozilla), “[\<main>](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/main).”

*Spotted an error or a change? Write to me from the [home page](https://www.devjpt.com/en/): every correction is dated at the bottom of the article.*
