# Webpage to Markdown: Clean Text for LLMs and RAG (`variegated_binturong/webpage-to-markdown`) Actor

Paste URLs and get the main text of each public page as clean Markdown for LLMs and RAG: title, description, language, headings, lists, links, tables, word count. Menus, footers and cookie banners removed. HTTP only, no browser, robots.txt respected. Failed pages never charged.

- **URL**: https://apify.com/variegated_binturong/webpage-to-markdown.md
- **Developed by:** [Luigi Fiano](https://apify.com/variegated_binturong) (community)
- **Categories:** AI, Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$1.00 / 1,000 page rows

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Webpage to Markdown: Clean Text for LLMs and RAG

Paste a list of URLs and get one row per page with its main text as clean Markdown: headings, paragraphs, lists, links, tables, code blocks and quotes, ready for an LLM prompt, a RAG index, an AI agent or a search tool. Menus, header, footer, sidebars, cookie banners, share buttons and scripts are removed.

Each row also has the page title, meta description, language, canonical URL, word count and how many internal and external links the text holds. Pages are read with plain HTTP requests (no browser), so runs are fast and light, and robots.txt is respected by default.

### What it is for

- **RAG and chatbots**: turn help-center articles, documentation, blog posts or product pages into Markdown you can split by heading and load into a vector database.
- **LLM prompts and AI agents**: give a model the clean text of a page instead of raw HTML, with far less noise.
- **Content audits and SEO**: title, description, language, canonical URL, word count and link counts for a list of pages, in one table.
- **Change monitoring**: schedule the same list and compare the Markdown from run to run.

### How it works

- **One request per page**: a GET that follows redirects and reads the HTML (up to 5 MB). Nothing else on the page is opened: no scripts, no images, no CSS.
- **robots.txt**: read once per site per run. A page it disallows is not requested and goes to the free `ERRORS` record with the rule that blocks it. When robots.txt answers with a server error, the pages of that site are skipped, as the robots.txt standard (RFC 9309) asks. Turn off `respectRobotsTxt` only for sites you own or have permission to crawl.
- **Main content**: the `<main>` element when the page has one, else the `<article>` that holds most of the text, else the whole body without the blocks made only of links. The field `contentSource` tells which (`main`, `article`, `body` or `full page`).
- **Markdown**: `#` headings, `**bold**`, `_italic_`, nested and numbered lists, links with absolute URLs, GitHub-style tables, fenced code blocks with their language, quotes. Tables used only for layout become plain paragraphs.
- **What it cannot see**: text that a page builds with JavaScript after loading (single-page apps). Those pages are reported as `no text found in the HTML` and are not charged. The parser and the Markdown writer are written for this Actor and handle broken HTML, but a page with a very unusual structure can keep a menu line or lose a box.
- **No personal data**: email addresses in the text become `[email]`, phone links become `[phone]`, mailto and tel links are dropped and comment sections are removed.

### Input

| Field | What it does | Default |
|---|---|---|
| `urls` | One page URL per line (spaces also separate). `https://` is added when missing, duplicates are removed, lines starting with `#` are comments | required |
| `respectRobotsTxt` | Skip the pages that robots.txt disallows | true |
| `extractMainContent` | Keep only the main text; off: the whole body (scripts and hidden elements are still removed) | true |
| `includeLinks` | Links as `[text](url)`; off: only the link text | true |
| `includeImages` | Images as `![alt](url)` | false |
| `maxCharacters` | Cut the Markdown of each page after this many characters (0: no limit, hard cap 2,000,000) | 0 |
| `concurrency`, `timeoutSecs`, `maxRetries` | Speed and resilience | 5, 30, 1 |
| `maxUrls`, `maxResults` | Safety caps (0: no limit on rows) | 10000, 0 |

```json
{
  "urls": [
    "https://en.wikipedia.org/wiki/Markdown",
    "https://www.gnu.org/philosophy/free-sw.html",
    "https://example.com"
  ],
  "respectRobotsTxt": true,
  "extractMainContent": true
}
```

### Output

One row per page. This row comes from the Actor's own test, on a sample blog page:

```json
{
  "type": "page",
  "url": "https://www.example.com/blog/pour-over",
  "finalUrl": "https://www.example.com/blog/pour-over",
  "redirected": false,
  "statusCode": 200,
  "title": "How to Brew Pour-Over Coffee | Example Coffee Blog",
  "description": "A step-by-step pour-over guide: grind, water temperature and timing.",
  "language": "en",
  "canonicalUrl": "https://www.example.com/blog/pour-over",
  "markdown": "# How to brew pour-over coffee\n\nPour-over gives a **clean, bright cup**. You need a dripper, a filter and a [burr grinder](https://www.example.com/shop/grinders).\n\n## Steps\n\n1. Heat the water to 94 °C.\n2. Grind 15 g of coffee, medium-fine.\n3. Pour 250 g of water in three rounds.\n\n| Dose | Water | Time |\n| --- | --- | --- |\n| 15 g | 250 g | 3 min |\n\nMore in the [brewing guide](https://www.example.org/brewing-guide).",
  "wordCount": 62,
  "characterCount": 418,
  "internalLinks": 1,
  "externalLinks": 1,
  "contentSource": "main",
  "markdownTruncated": false,
  "htmlBytes": 1046,
  "htmlTruncated": false,
  "input": "https://www.example.com/blog/pour-over",
  "error": null,
  "scrapedAt": "2026-11-09T05:00:00.000Z"
}
```

The sample page also had a cookie banner, a menu with three links and a footer: none of them is in the Markdown.

- `wordCount` counts the words of the Markdown without link addresses; hyphenated words count as two.
- `internalLinks` and `externalLinks` count the distinct links of the extracted text (same site, www. or not, versus other sites).
- `markdownTruncated` is true when `maxCharacters` (or the hard cap) cut the text.

#### Pages that cannot be read (not charged)

A page that does not answer, is blocked, is not HTML, has no text in its HTML or is disallowed by robots.txt never becomes a dataset row, so it costs nothing. It is listed with the reason in the `ERRORS` record of the key-value store (also in the Output tab):

```json
{ "type": "error", "url": "https://this-domain-does-not-exist-4821.com/page", "input": "https://this-domain-does-not-exist-4821.com/page", "finalUrl": null, "statusCode": null, "error": "request failed: domain not found (DNS)", "scrapedAt": "2026-11-09T05:00:00.000Z" }
```

Other reasons you can see: `disallowed by robots.txt (Disallow: /checkout): the page was not fetched; set respectRobotsTxt to false to skip the check`, `request failed: timeout`, `access denied (HTTP 403): the site blocks automated requests or needs a login, nothing was bypassed`, `blocked by a bot check (Cloudflare, HTTP 403): nothing was bypassed`, `page not found (HTTP 404)`, `server error (HTTP 503)`, `not an HTML page (application/pdf)`, `no text found in the HTML: the page may need JavaScript to show its content`.

#### Summary

The `SUMMARY` record has the run totals: `pagesChecked`, `pagesOk`, `pagesWithError`, `disallowedByRobotsTxt`, `rows`, `words` and `stoppedEarly`.

### Pricing

Pay per result: **$0.001 per page row** in the dataset ($1 per 1,000 pages). Pages that cannot be read, are not HTML or are disallowed by robots.txt are not charged: they go to the free `ERRORS` record. Use `maxResults` to cap the cost of a run.

### Tips

- For RAG, split the Markdown on `## ` headings: each section keeps its own title.
- Big lists: raise `concurrency` (up to 20) and the run timeout in the run options; give the run 1 GB of memory at high concurrency. robots.txt is read once per site, however many pages of that site you give.
- To read a whole site, give its page URLs (for example from its sitemap). This Actor reads the pages you list and does not follow links.

### Notes

- Only public pages: no login, no cookies sent, no proxies, no CAPTCHA solving. Sites that block automated requests are reported, not bypassed.
- You are responsible for how you use the text you collect (copyright and the terms of each site).
- Not affiliated with any of the sites you read.

# Actor input Schema

## `urls` (type: `array`):

One public page per line (spaces also separate). A missing https:// is added, the #fragment is ignored, duplicates are removed and lines starting with # are comments.

## `respectRobotsTxt` (type: `boolean`):

Read each site's robots.txt once per run and skip the pages it disallows (they go to the free ERRORS record with the rule). Turn it off only for sites you own or have permission to crawl.

## `extractMainContent` (type: `boolean`):

Keep only the main text: menus, header, footer, sidebars, cookie banners, share buttons, comments and hidden elements are removed. Off: the whole page body (scripts, styles and hidden elements are still removed).

## `includeLinks` (type: `boolean`):

Write links as [text](url) with absolute URLs. Off: only the link text. Links are counted either way.

## `includeImages` (type: `boolean`):

Write images as ![alt](url) with absolute URLs. Off by default: images rarely help an LLM.

## `maxCharacters` (type: `integer`):

Cut the Markdown of a page after this many characters (markdownTruncated is then true). 0: no limit, up to the hard cap of 2,000,000 characters.

## `concurrency` (type: `integer`):

How many pages are read at the same time.

## `timeoutSecs` (type: `integer`):

Give up on a page after this many seconds.

## `maxRetries` (type: `integer`):

How many times a page is requested again after a timeout, a 429 or a 5xx answer. Retry-After is honoured (max 10 s).

## `maxUrls` (type: `integer`):

Safety cap on the number of pages processed.

## `maxResults` (type: `integer`):

Stop after this many dataset rows. 0: no limit.

## Actor input object example

```json
{
  "urls": [
    "https://en.wikipedia.org/wiki/Markdown",
    "https://www.gnu.org/philosophy/free-sw.html"
  ],
  "respectRobotsTxt": true,
  "extractMainContent": true,
  "includeLinks": true,
  "includeImages": false,
  "maxCharacters": 0,
  "concurrency": 5,
  "timeoutSecs": 30,
  "maxRetries": 1,
  "maxUrls": 10000,
  "maxResults": 0
}
```

# Actor output Schema

## `overview` (type: `string`):

No description

## `markdown` (type: `string`):

No description

## `results` (type: `string`):

No description

## `summary` (type: `string`):

No description

## `errors` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "urls": [
        "https://en.wikipedia.org/wiki/Markdown",
        "https://www.gnu.org/philosophy/free-sw.html"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("variegated_binturong/webpage-to-markdown").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "urls": [
        "https://en.wikipedia.org/wiki/Markdown",
        "https://www.gnu.org/philosophy/free-sw.html",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("variegated_binturong/webpage-to-markdown").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "urls": [
    "https://en.wikipedia.org/wiki/Markdown",
    "https://www.gnu.org/philosophy/free-sw.html"
  ]
}' |
apify call variegated_binturong/webpage-to-markdown --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,variegated_binturong/webpage-to-markdown"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/sT8y0j2liGhgSOdqB/builds/DfIv9YKupKTzRvWdV/openapi.json
