HTML to Markdown for LLM & RAG — Clean Page Content + Chunks
Turn web pages or raw HTML into clean Markdown for LLMs, RAG and AI agents: main content only (no menus, ads, footers), absolute links, GFM tables, code blocks with language, title and metadata, optional chunks. Respects robots.txt. Pay per page.
Run it on Apify →Feed it web page URLs (or your own HTML) and get clean Markdown ready for an LLM, a RAG index or an AI agent: only the main content, no menus, cookie banners, sidebars or footers, with absolute links, proper tables and fenced code blocks. Optional chunking on paragraph boundaries, each chunk tagged with its section heading.
Why Markdown: it keeps the structure (headings, lists, tables, code) that models rely on, at a fraction of the tokens of raw HTML.
Features
- Main content extraction with a Readability-style algorithm (the one behind Firefox Reader View); falls back to the whole body when the page has no article.
- GitHub-flavored Markdown:
#headings,-lists, pipe tables, fenced code blocks that keep their language (`python). - Absolute links, inline or as numbered references, or dropped entirely to save tokens; link tooltips and empty image links removed.
- Metadata: title, meta description, language, final URL after redirects, HTTP status, word count, list of links.
- Chunks for embeddings: size in characters, optional overlap, never cuts inside a code block.
- Your own HTML: paste HTML strings (from an email, a CMS export, another scraper) with an optional base URL for relative links.
- Correct character sets (UTF-8, ISO-8859-1, Windows-1252...) from the HTTP header or the page's
<meta charset>.
What it is for
- Building a knowledge base / RAG index from documentation, help centers or blog posts.
- Giving an AI agent readable page content through the API, Make, Zapier or n8n.
- Summarizing or translating articles with an LLM without paying for HTML tokens.
- Archiving pages as plain-text Markdown in Git, Notion or Obsidian.
- Combine it with a sitemap extractor to convert a whole documentation site.
Input example
{
"startUrls": ["https://en.wikipedia.org/wiki/Markdown"],
"htmlItems": [{ "html": "<h1>Notes</h1><p>Hello <a href='/a'>link</a></p>", "url": "https://example.com/", "name": "notes" }],
"extractionMode": "main",
"linkStyle": "inline",
"chunkSize": 2000,
"chunkOverlap": 200
}
startUrls— pages to fetch;htmlItems— HTML you provide (nothing fetched).extractionMode—main(default) orfull.linkStyle—inline,referencedortext;includeImages,includeLinkList.chunkSize,chunkOverlap— chunking (0 = off).maxConcurrency,maxPageSizeMb,maxResults— limits;maxResultscaps the cost.
Output example
One dataset row per page:
{
"index": 1,
"url": "https://en.wikipedia.org/wiki/Markdown",
"finalUrl": "https://en.wikipedia.org/wiki/Markdown",
"statusCode": 200,
"title": "Markdown",
"description": null,
"language": "en",
"extraction": "main",
"wordCount": 5053,
"markdown": "From Wikipedia, the free encyclopedia\n\n**Markdown** is a lightweight markup language for creating formatted text...",
"links": [{ "text": "lightweight markup language", "url": "https://en.wikipedia.org/wiki/Lightweight_markup_language" }],
"chunks": [{ "index": 0, "heading": "History", "text": "## History\n\n...", "chars": 1987 }],
"error": null
}
Good to know
- Honest fetching: plain HTTP requests with the Actor's own User-Agent (
OpenRegistry-HtmlToMarkdown),robots.txtchecked before every request and after each redirect, requests to the same site spaced out. No headless browser, no imitation of a real browser, no proxies, no CAPTCHA solving. Pages that forbid automated access, need a login, or only render with JavaScript come back as an error row and are not charged. - Only use it on content you are allowed to process; respect the site's terms and copyright.
- Main-content detection is heuristic: on unusual layouts (home pages, product grids) try
extractionMode: "full".
Pricing
$0.001 per page ($1 per 1,000 pages), chunks included. Failed pages are free. Set a maximum charge per run in the Apify console and the Actor stops cleanly when it is reached.
Open HTML to Markdown for LLM & RAG on Apify →