# Webpage to Markdown – Clean Content for LLM & RAG (`adamplaenitz/webpage-to-markdown`) Actor

Convert web pages into clean Markdown for LLMs, RAG and AI agents: main-content extraction (Readability), title, description, language, word and link counts, optional chunking with overlap. Plain HTTP, no browser, respects robots.txt.

- **URL**: https://apify.com/adamplaenitz/webpage-to-markdown.md
- **Developed by:** [Adam Plänitz](https://apify.com/adamplaenitz) (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

from $1.00 / 1,000 page converteds

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 Content for LLM & RAG

**Turn any list of web pages into clean Markdown for LLMs, RAG pipelines and AI agents.** The Actor fetches each URL with a plain HTTP request (no browser), extracts the main content with Mozilla Readability – menus, headers, footers, sidebars, cookie banners and scripts are dropped – and converts it to Markdown with headings, lists, tables, code blocks and absolute links. You also get title, description, language, word and link counts and, optionally, ready-to-embed chunks with overlap. Export as JSON, CSV or Excel, or connect to LangChain, LlamaIndex, Make, Zapier, n8n or webhooks.

### What does it do?

For every URL:

1. **Fetch** the page with one HTTP GET (redirects followed, charset detected from header, BOM or `<meta>`). robots.txt is respected by default.
2. **Extract the main content** with [Mozilla Readability](https://github.com/mozilla/readability) (the engine behind Firefox Reader View). If Readability finds too little (e.g. on home pages or documentation portals), the `<main>` element or the cleaned page body is used instead – the `extractionMethod` field tells you which.
3. **Convert to Markdown** with [Turndown](https://github.com/mixmark-io/turndown) + GitHub-flavoured Markdown tables: ATX headings (`#`), `-` bullet lists, fenced code blocks, tables (cells with lists are flattened so the table stays valid), absolute link URLs. Citation markers like `[1]` are removed by default; images are optional.
4. **Chunk** (optional): split the Markdown into pieces of at most *N* characters with overlap, cut at paragraph, line or sentence boundaries. Every chunk carries its character offset and the nearest heading above it – useful as metadata in a vector store.

Plain-text and Markdown responses (`text/plain`, `text/markdown`) are passed through unchanged.

### Who is it for?

- **RAG / chatbot builders:** feed documentation, help-center or knowledge-base pages into a vector database.
- **AI agents and LLM apps:** give a model the readable content of a page instead of 200 KB of HTML – far fewer tokens.
- **Content and SEO teams:** archive articles as Markdown, compare word counts, migrate content to a CMS or static site generator.

### Input

| Field | Default | Description |
|---|---|---|
| URLs | – | One per line. Bare domains become `https://domain/`. Duplicates are removed. |
| Content | Main content | *Main content* (Readability with fallback) or *Full page* (whole body without scripts, navigation, header, footer). |
| Keep links | on | Markdown links with absolute URLs; off = link text only (saves tokens). |
| Keep images | off | `![alt](url)` references. |
| Remove citation markers | on | Drops `[1]`, `[citation needed]` etc. |
| Chunk size | 0 (off) | Maximum characters per chunk, e.g. 2000. |
| Chunk overlap | 200 | Characters shared by consecutive chunks (at most half the chunk size). |
| Respect robots.txt | on | Disallowed pages get a free error row. |
| Parallel requests | 5 | 1–30; requests to the same host are spaced by 0.3 s. |
| Timeout per page | 30 s | |
| Maximum page size | 10 MB | |
| Proxy | none | Only needed for sites that block cloud servers. |

### Output example (shortened)

```json
{
  "url": "https://en.wikipedia.org/wiki/Markdown",
  "finalUrl": "https://en.wikipedia.org/wiki/Markdown",
  "statusCode": 200,
  "title": "Markdown - Wikipedia",
  "description": null,
  "language": "en",
  "canonicalUrl": "https://en.wikipedia.org/wiki/Markdown",
  "siteName": null,
  "publishedTime": null,
  "markdown": "From Wikipedia, the free encyclopedia\n\n| Markdown |\n| --- |\n…\n\n**Markdown** is a [lightweight markup language](https://en.wikipedia.org/wiki/Lightweight_markup_language \"Lightweight markup language\") for creating formatted text using a plain-text editor. …",
  "wordCount": 3013,
  "charCount": 37200,
  "linksCount": 327,
  "imagesCount": 2,
  "chunkCount": 23,
  "chunks": [
    { "index": 0, "text": "From Wikipedia, the free encyclopedia …", "charStart": 0, "charCount": 1987, "heading": null },
    { "index": 1, "text": "… ## History …", "charStart": 1795, "charCount": 1968, "heading": "History" }
  ],
  "extractionMethod": "readability",
  "contentType": "text/html",
  "responseTimeMs": 412,
  "warning": null,
  "fetchedAt": "2026-11-17T21:00:00.000Z",
  "errorCode": null,
  "error": null
}
```

`chunkCount` and `chunks` only appear when a chunk size is set. `linksCount` counts the http(s) links in the extracted content. URLs that could not be converted produce a row with `errorCode` and `error` (e.g. `HTTP_404`, `ROBOTS_TXT`, `ENOTFOUND`, `UNSUPPORTED_CONTENT_TYPE`, `NO_TEXT`). Pages with fewer than 50 words get a `warning`.

The **Overview** table shows URL, title, language, words, links, chunks, extraction method, status and the Markdown. The run summary (key-value store record `RUN-SUMMARY`) lists counts, extraction methods and error codes.

### Pricing and speed

See the **Pricing** tab. You pay per converted page; **rows for pages that could not be converted (HTTP errors, DNS errors, timeouts, robots.txt, unsupported content types, pages without any text) are free**. Duplicates are removed before fetching. You can set a maximum cost per run – the Actor stops cleanly when it is reached.

No browser is needed, so runs are fast and cheap. In a cloud test with the default 1 GB memory, 50 mixed pages (20 long Wikipedia articles, documentation pages, news home pages, the 280-chunk RFC 9110) took 45 seconds including chunking. Very long pages take a few seconds each; more memory also means more CPU and faster parsing.

### Data, licences and responsible use

- The Actor only fetches the URLs you provide (no crawling) and respects robots.txt by default. **The converted content belongs to the respective website owners** – check the site's terms and copyright before reusing it (e.g. Wikipedia text is CC BY-SA and requires attribution).
- Private, loopback and internal addresses are refused.
- Open-source components: Mozilla Readability (Apache-2.0), Turndown and turndown-plugin-gfm (MIT), linkedom (ISC), robots-parser (MIT). Not affiliated with Mozilla or any of the websites mentioned.

### Limits

- **No JavaScript rendering.** Pages that load their content with JavaScript only (many single-page apps) return little or no text – you get a warning or a free `NO_TEXT` row.
- Sites with bot protection may answer with 403/429 (free row); a proxy can help.
- Main-content detection is heuristic. On home pages, portals and listing pages there is no single "article" – use *Full page* if you need everything.
- PDFs, images and other binary files are not converted.
- One URL = one page; links are not followed.

Questions or feature requests? Please open an issue in the **Issues** tab.

# Actor input Schema

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

Web pages to convert, one per line (e.g. https://en.wikipedia.org/wiki/Markdown). Bare domains are fetched as https://domain/. Duplicates are removed. Each page is fetched with one plain HTTP request – no browser, so pages that build their content with JavaScript only may come back empty.

## `contentMode` (type: `string`):

Main content: the article text is detected with Mozilla Readability (menus, headers, footers, sidebars and cookie banners are dropped); if that finds too little, the <main> element or the cleaned page is used. Full page: the whole body without scripts, navigation, header and footer.

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

Keep hyperlinks as Markdown links with absolute URLs. Switch off for plain text (the link text is kept, the URL is dropped) – saves tokens.

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

Keep images as Markdown image references with alt text and absolute URL. Off by default because image URLs rarely help an LLM.

## `removeCitationMarkers` (type: `boolean`):

Remove footnote markers such as \[1] or \[citation needed] (common on Wikipedia) – noise for embeddings.

## `chunkSize` (type: `integer`):

Optional. If set (e.g. 2000), the Markdown is also split into chunks of at most this many characters, preferably at paragraph, line or sentence boundaries; each chunk carries its nearest heading. 0 = no chunking.

## `chunkOverlap` (type: `integer`):

How many characters consecutive chunks share (at most half the chunk size). Only used when a chunk size is set.

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

Skip pages that the robots.txt of the site disallows for crawlers (free error row). Switch off only for sites you own or may access.

## `maxConcurrency` (type: `integer`):

How many pages are fetched at the same time (1–30). Requests to the same host are additionally spaced by 0.3 seconds.

## `requestTimeoutSecs` (type: `integer`):

A page that does not load within this time is reported as a timeout (free row).

## `maxPageSizeMb` (type: `integer`):

Larger responses are aborted and reported as an error (free row).

## `proxyConfiguration` (type: `object`):

Optional. Only needed if a site blocks requests from cloud servers.

## Actor input object example

```json
{
  "urls": [
    "https://en.wikipedia.org/wiki/Markdown",
    "https://docs.apify.com/"
  ],
  "contentMode": "main",
  "includeLinks": true,
  "includeImages": false,
  "removeCitationMarkers": true,
  "chunkSize": 0,
  "chunkOverlap": 200,
  "respectRobotsTxt": true,
  "maxConcurrency": 5,
  "requestTimeoutSecs": 30,
  "maxPageSizeMb": 10,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

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

One item per URL with Markdown, metadata and optional chunks (plus free rows for URLs that could not be converted).

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

Counts of converted and failed pages, extraction methods, robots.txt and error statistics.

# 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://docs.apify.com/"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("adamplaenitz/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://docs.apify.com/",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("adamplaenitz/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://docs.apify.com/"
  ]
}' |
apify call adamplaenitz/webpage-to-markdown --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,adamplaenitz/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/6k8RWIiO3t1fz0yTP/builds/tOaEFEf73umTk9bD1/openapi.json
