# Website to Markdown – Clean LLM & RAG Content Extractor (`dataquarry/website-to-markdown`) Actor

Convert any public web page to clean, LLM-ready Markdown with metadata — by URL, a list of URLs, or a whole-site crawl. Strips nav/ads/boilerplate, keeps headings/lists/tables/code. Respects robots.txt. No API key.

- **URL**: https://apify.com/dataquarry/website-to-markdown.md
- **Developed by:** [Daniel Brenner](https://apify.com/dataquarry) (community)
- **Categories:** Developer tools, AI, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 results

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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## Website to Markdown — Clean LLM & RAG Content Extractor

**Convert any public web page to clean, LLM-ready Markdown — by URL, a list of URLs, or a whole-site crawl.** No API key, no browser to manage. The tool fetches the page, strips navigation, ads and boilerplate, and returns tidy Markdown plus structured metadata — ideal for feeding LLMs, building RAG pipelines, archiving articles, or training datasets.

It's the no-fuss answer to "**how do I turn a website into Markdown for ChatGPT / a vector database / an AI agent?**" — give it URLs, get Markdown back as JSON, CSV or Excel.

### What it does

- **HTML → clean Markdown**, with headings, lists, tables, code blocks and links preserved (GitHub-flavored).
- **Main-content extraction** — removes menus, headers, footers, sidebars, cookie banners and ads so the Markdown is just the article, not the chrome. (Or keep the full page if you prefer.)
- **Structured metadata** per page — title, description, author, published date, language, site name, canonical URL.
- **RAG-ready extras** — optional token-count estimate and overlapping chunks for retrieval-augmented generation.
- **Three modes** — a single page, a list of pages, or crawl a site (same-domain link following, depth- and page-limited).
- **Respects `robots.txt`** and sends a descriptive User-Agent. Public pages only — no logins, no paywalls.

### What you get (per page)

| field | description |
|-------|-------------|
| `url` / `finalUrl` | requested URL, and the final URL after redirects (if different) |
| `title`, `description`, `author`, `publishedDate`, `lang`, `siteName` | page metadata (honest-null when not present) |
| `canonicalUrl` | the page's canonical link, if declared |
| `markdown` | the clean, LLM-ready Markdown |
| `wordCount`, `tokenEstimate` | length, plus an **approximate** LLM token count (a heuristic estimate, not exact) |
| `chunks` | optional RAG chunks (`{index, text}`) when "Chunk for RAG" is on |
| `links`, `images` | optional lists of absolute links / image URLs on the page |
| `httpStatus`, `fetchedAt`, `robotsAllowed` | response status, fetch time, robots check result |

Anything a page doesn't expose comes back as `null` — never guessed.

### How to use it

**Single page or a list:**

```json
{ "startUrls": ["https://example.com/blog/post"], "mode": "single" }
````

```json
{ "startUrls": ["https://a.com/p1", "https://a.com/p2"], "mode": "list" }
```

**Crawl a site for a RAG dataset:**

```json
{
  "startUrls": ["https://docs.example.com/"],
  "mode": "crawl",
  "maxCrawlDepth": 2,
  "maxPages": 100,
  "sameDomainOnly": true,
  "chunkForRag": true,
  "chunkSize": 2000,
  "chunkOverlap": 200
}
```

Set `contentMode` to `main` (default — just the article) or `full` (the whole page). Toggle `includeLinks` / `includeImages` to also collect a page's links and images.

### Why this tool

- **No API key, no headless browser to babysit** — give it URLs, get Markdown.
- **Clean output** — boilerplate-stripped main content, not a raw HTML dump.
- **LLM-first** — Markdown + metadata + optional chunking and token estimate, the exact shape RAG and fine-tuning pipelines want.
- **Polite & transparent** — respects `robots.txt`, identifies itself, fetches only public pages one at a time.

Pricing is **pay-per-result: $2 per 1,000 pages** — you only pay for pages successfully converted. Export as JSON, CSV or Excel.

### Responsible use

This tool reformats the public pages you point it at — the same content a browser would load. You're responsible for how you use content from sites you don't own (respect each site's terms and applicable copyright). The tool honors `robots.txt` and never bypasses logins or paywalls.

### FAQ

**Do I need an API key?**

No. Give it one or more URLs and run it — no key, no quota.

**Can it convert a whole website, not just one page?**

Yes — use `crawl` mode with a start URL. It follows same-domain links up to the depth and page limits you set, converting each page to Markdown.

**Is the Markdown ready for an LLM / RAG?**

Yes — that's the point. You get clean Markdown plus metadata, an approximate token count, and optional overlapping chunks for retrieval-augmented generation.

**How much does it cost?**

Pay-per-result: $2 per 1,000 pages — you only pay for the pages you actually get.

# Actor input Schema

## `startUrls` (type: `array`):

Web page URLs to convert to Markdown. In crawl mode these are the starting pages.

## `mode` (type: `string`):

single = first URL only; list = every URL given; crawl = follow same-domain links from each start URL.

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

main = extract the primary article/content and strip nav, ads and boilerplate; full = convert the whole page.

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

Maximum number of pages to return.

## `maxCrawlDepth` (type: `integer`):

Crawl mode only: how many link-hops from each start URL to follow.

## `maxPages` (type: `integer`):

Crawl mode only: hard cap on pages visited.

## `sameDomainOnly` (type: `boolean`):

Crawl mode only: only follow links on the same domain as the start URL.

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

Also output the list of links found on each page.

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

Also output the list of image URLs found on each page.

## `computeTokenEstimate` (type: `boolean`):

Add an approximate LLM token count for each page's Markdown (a heuristic estimate, not exact).

## `chunkForRag` (type: `boolean`):

Also split each page's Markdown into overlapping chunks for retrieval-augmented generation.

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

Target chunk size in characters when chunking for RAG.

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

Overlap between consecutive chunks when chunking for RAG.

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

Skip URLs disallowed by the site's robots.txt for our user-agent.

## `requestDelayMs` (type: `integer`):

Optional politeness delay between pages, in milliseconds (pages are fetched one at a time).

## Actor input object example

```json
{
  "startUrls": [
    "https://en.wikipedia.org/wiki/OpenStreetMap"
  ],
  "mode": "list",
  "contentMode": "main",
  "maxResults": 50,
  "maxCrawlDepth": 1,
  "maxPages": 50,
  "sameDomainOnly": true,
  "includeLinks": false,
  "includeImages": false,
  "computeTokenEstimate": true,
  "chunkForRag": false,
  "chunkSize": 2000,
  "chunkOverlap": 200,
  "respectRobotsTxt": true,
  "requestDelayMs": 0
}
```

# 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 = {
    "startUrls": [
        "https://en.wikipedia.org/wiki/OpenStreetMap"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("dataquarry/website-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 = { "startUrls": ["https://en.wikipedia.org/wiki/OpenStreetMap"] }

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

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

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

```

## CLI example

```bash
echo '{
  "startUrls": [
    "https://en.wikipedia.org/wiki/OpenStreetMap"
  ]
}' |
apify call dataquarry/website-to-markdown --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=dataquarry/website-to-markdown",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Website to Markdown – Clean LLM & RAG Content Extractor",
        "description": "Convert any public web page to clean, LLM-ready Markdown with metadata — by URL, a list of URLs, or a whole-site crawl. Strips nav/ads/boilerplate, keeps headings/lists/tables/code. Respects robots.txt. No API key.",
        "version": "0.0",
        "x-build-id": "xVZvLslVTu6RrYQDy"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/dataquarry~website-to-markdown/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-dataquarry-website-to-markdown",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/dataquarry~website-to-markdown/runs": {
            "post": {
                "operationId": "runs-sync-dataquarry-website-to-markdown",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/dataquarry~website-to-markdown/run-sync": {
            "post": {
                "operationId": "run-sync-dataquarry-website-to-markdown",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "startUrls": {
                        "title": "URLs",
                        "type": "array",
                        "description": "Web page URLs to convert to Markdown. In crawl mode these are the starting pages.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "mode": {
                        "title": "Mode",
                        "enum": [
                            "single",
                            "list",
                            "crawl"
                        ],
                        "type": "string",
                        "description": "single = first URL only; list = every URL given; crawl = follow same-domain links from each start URL.",
                        "default": "list"
                    },
                    "contentMode": {
                        "title": "Content",
                        "enum": [
                            "main",
                            "full"
                        ],
                        "type": "string",
                        "description": "main = extract the primary article/content and strip nav, ads and boilerplate; full = convert the whole page.",
                        "default": "main"
                    },
                    "maxResults": {
                        "title": "Max results (pages)",
                        "minimum": 1,
                        "type": "integer",
                        "description": "Maximum number of pages to return.",
                        "default": 50
                    },
                    "maxCrawlDepth": {
                        "title": "Max crawl depth",
                        "minimum": 0,
                        "type": "integer",
                        "description": "Crawl mode only: how many link-hops from each start URL to follow.",
                        "default": 1
                    },
                    "maxPages": {
                        "title": "Max pages to crawl",
                        "minimum": 1,
                        "type": "integer",
                        "description": "Crawl mode only: hard cap on pages visited.",
                        "default": 50
                    },
                    "sameDomainOnly": {
                        "title": "Same domain only",
                        "type": "boolean",
                        "description": "Crawl mode only: only follow links on the same domain as the start URL.",
                        "default": true
                    },
                    "includeLinks": {
                        "title": "Include links list",
                        "type": "boolean",
                        "description": "Also output the list of links found on each page.",
                        "default": false
                    },
                    "includeImages": {
                        "title": "Include images list",
                        "type": "boolean",
                        "description": "Also output the list of image URLs found on each page.",
                        "default": false
                    },
                    "computeTokenEstimate": {
                        "title": "Estimate token count",
                        "type": "boolean",
                        "description": "Add an approximate LLM token count for each page's Markdown (a heuristic estimate, not exact).",
                        "default": true
                    },
                    "chunkForRag": {
                        "title": "Chunk for RAG",
                        "type": "boolean",
                        "description": "Also split each page's Markdown into overlapping chunks for retrieval-augmented generation.",
                        "default": false
                    },
                    "chunkSize": {
                        "title": "Chunk size (characters)",
                        "minimum": 200,
                        "type": "integer",
                        "description": "Target chunk size in characters when chunking for RAG.",
                        "default": 2000
                    },
                    "chunkOverlap": {
                        "title": "Chunk overlap (characters)",
                        "minimum": 0,
                        "type": "integer",
                        "description": "Overlap between consecutive chunks when chunking for RAG.",
                        "default": 200
                    },
                    "respectRobotsTxt": {
                        "title": "Respect robots.txt",
                        "type": "boolean",
                        "description": "Skip URLs disallowed by the site's robots.txt for our user-agent.",
                        "default": true
                    },
                    "requestDelayMs": {
                        "title": "Delay between requests (ms)",
                        "minimum": 0,
                        "type": "integer",
                        "description": "Optional politeness delay between pages, in milliseconds (pages are fetched one at a time).",
                        "default": 0
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
