# Website to Markdown (`datahamster/website-to-markdown`) Actor

Website to Markdown converter for LLM and RAG pipelines. Turn any URL into clean main-content Markdown with title, description, language, links and images. Optional site crawling, JS rendering and automatic proxy escalation on Cloudflare blocks. Pay only for pages that succeed.

- **URL**: https://apify.com/datahamster/website-to-markdown.md
- **Developed by:** [Viktor Dubnytskiy](https://apify.com/datahamster) (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 $0.80 / 1,000 result items

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## Website to Markdown

Turn any web page into clean Markdown for an LLM, a RAG index or a vector database. Paste URLs (or switch on crawling) and get one row per page: the main content as Markdown, with navigation, footers, sidebars and cookie banners left out, plus title, meta description, language, links and images.

**Try it:** the prefilled example returns 1 row in about 25 seconds and costs about $0.001. Results cost $1 per 1,000.

### What you get

Real rows from a test run with a Python docs page, a BBC News article and an npm page behind Cloudflare:

| page | words | proxy tier | status |
|---|---|---|---|
| Coroutines and tasks (docs.python.org) | 6858 | none | 200 |
| India's opposition rallies against voter roll revision (bbc.com) | 899 | none | 200 |
| react - npm (npmjs.com, Cloudflare) | 123 | unblocker (escalated automatically) | 200 |

One row from the example dataset (the prefilled input). The Markdown is cut here for space; in the dataset it is the whole page:

```json
{
  "url": "https://docs.python.org/3/library/asyncio-task.html",
  "finalUrl": "https://docs.python.org/3/library/asyncio-task.html",
  "statusCode": 200,
  "title": "Coroutines and tasks — Python 3.15.2 documentation",
  "description": "This section outlines high-level asyncio APIs to work with coroutines and Tasks. Coroutines, Awaitables, Creating tasks, Task cancellation, Task groups, Sleeping, Running tasks concurrently, Eager ...",
  "language": "en",
  "markdown": "# Coroutines and tasks\n\nThis section outlines high-level asyncio APIs to work with coroutines and Tasks.\n\n## Coroutines\n\n**Source code:** Lib/asyncio/coroutines.py\n\nCoroutines declared with the async/await syntax is the preferred way of writing asyncio applications. For example, the following snippet of code prints “hello”, ...",
  "textLength": 44186,
  "wordCount": 6858,
  "fetchedAt": "2026-11-01T18:25:23.646920Z",
  "contentHash": "5310d219f80a87aa9e1f7832e3929796",
  "tierUsed": "none",
  "extractor": "trafilatura",
  "error": null
}
```

Full row: `url`, `finalUrl`, `statusCode`, `title`, `description`, `language`, `canonicalUrl`, `markdown`, `textLength`, `wordCount`, `links` (with `includeLinks`), `images` (with `includeImages`), `contentType`, `contentHash`, `extractor`, `tierUsed`, `fetchMode`, `depth`, `fetchedAt`, `error`.

### Use cases

- **RAG and vector databases**: crawl a documentation site and load clean Markdown chunks instead of raw HTML full of menus.
- **LLM agents and summaries**: give a model the article text of a URL in a few hundred tokens, not the 300 KB page.
- **Content change alerts**: run the same URLs on a schedule in monitor mode and get a row only when a page's text really changed.

### Try it in 10 seconds

**One page**: hit **Start**, the input already works (`urls: ["https://docs.python.org/3/library/asyncio-task.html"]`).

**Crawl a docs section**:

```json
{
  "urls": ["https://docs.python.org/3/library/asyncio.html"],
  "crawl": true,
  "maxPages": 50,
  "maxDepth": 2,
  "includeUrlPatterns": ["https://docs.python.org/3/library/asyncio-*"]
}
```

**Monitor mode**: save a task with

```json
{
  "mode": "monitor",
  "monitorStateId": "pricing-pages",
  "urls": ["https://example.com/pricing", "https://example.com/terms"],
  "webhookUrl": "https://your-endpoint.example.com/hook"
}
```

and schedule it. Each run charges one `monitor-check` event and returns only pages that are new or whose Markdown changed since the last run (one `change` event each).

### Related actors

- [Cloudflare / DataDome Bypass: Protected Page Change Monitor](https://apify.com/datahamster/protected-page-fetch-monitor) gives you raw text, CSS-selector or regex extraction from protected pages, with change alerts. Use it when you need one price or one paragraph, not the whole article.
- [Substack Scraper (posts, publications, likes, full text)](https://apify.com/datahamster/substack-posts) returns every post of a Substack publication with full text and metadata, without crawling.
- [Medium Articles Scraper (tags, authors, publications, claps)](https://apify.com/datahamster/medium-articles) lists the newest Medium stories for a tag, author or publication, which this actor cannot render past Medium's bot wall.

### How it works

1. **Fetch**: each page is requested with a real browser TLS fingerprint. With `proxyTier: auto` the actor starts without a proxy and steps up to datacenter, residential and Apify Web Unblocker only when the site answers with a block or a Cloudflare challenge. The tier that worked is remembered per domain, so the next pages of that site skip the dead tiers.
2. **Extract**: the main content is found with trafilatura. If a page has almost no article text (landing pages), the actor falls back to readability and then to the whole page body with nav, header, footer, aside, forms and cookie banners removed. The `extractor` field tells you which one was used.
3. **Crawl** (optional): links found on a page are queued breadth-first, filtered by domain, glob patterns, depth and the page budget. Tracking parameters (`utm_*`, `gclid`, `fbclid`, `ref`) are removed, canonical URLs are respected, and a page whose content repeats one already returned is skipped. Images, documents, feeds and archives are never queued. A link that redirects to another domain comes back as a free row with `error: "redirected off-domain"`.
4. **Pacing**: at least `domainDelaySecs` (1 s by default) between two requests to the same site.

### Input

| Field | Meaning | Default |
|---|---|---|
| `urls` | Pages to convert (start pages when crawling) | Python docs page |
| `crawl` | Follow links found on the pages | `false` |
| `maxPages`, `maxDepth` | Crawl budget and depth | `10`, `2` |
| `sameDomainOnly` | Follow only links on the start page's domain | `true` |
| `includeUrlPatterns`, `excludeUrlPatterns` | Glob filters for discovered links, e.g. `*/docs/*` | empty |
| `renderJs`, `waitFor` | Render with headless Chromium, optionally wait for a CSS selector | `false` |
| `proxyTier`, `proxyCountry` | `auto`, `none`, `datacenter`, `residential`, `unblocker` | `auto` |
| `includeLinks`, `includeImages` | Keep links / images in the Markdown and list them in the row | `false` |
| `domainDelaySecs`, `timeout` | Pause per domain, timeout per page (seconds) | `1`, `45` |
| `maxItems` | Stop after this many successful pages | `10` in the example, `100` otherwise |
| `mode`, `monitorStateId`, `webhookUrl`, `telegramBotToken`, `telegramChatId` | Monitor mode and alerts | `scrape` |

### Pricing

| Event | Price |
|---|---|
| result | $0.001 per successful page ($1 per 1,000) |
| failed page | free (listed with an `error` field) |
| monitor-check | $0.005 per monitor run |
| change | $0.001 per new or changed page in monitor mode |

Apify subscribers pay less: SILVER -10%, GOLD and higher -20%.

A page that fails (404, 5xx, a block on every tier, a PDF or other non-HTML file, a private address) is still listed in the dataset, free of charge. Proxy traffic and compute are billed by Apify on top, and residential or Unblocker traffic is used only when `auto` actually needs it.

**Found it useful?** A short review on the Store page helps other people find this actor. If something is wrong, open an issue on the actor page.

### Limits

- PDFs, images, JSON and other non-HTML files are skipped with a reason in `error` and are never downloaded. Pages larger than 10 MB are cut at 10 MB.
- Private, loopback, link-local and internal addresses (`localhost`, `10.x`, `169.254.169.254`, `*.internal`) are refused, also when a public URL redirects to them. Plain text and Markdown files are passed through as is.
- With `renderJs` every page opens a fresh browser, so it is several times slower. Give the run 2048 MB of memory. Some sites (Medium, for example) still block headless browsers.
- Pages are fetched one at a time, which keeps the per-domain pacing simple. Large crawls take a while.
- No login, no cookies, no paywalled content.

### FAQ

**Why is a page in the dataset with an empty `markdown`?** It failed, and the `error` field says why. Failed pages are not charged. If every page failed, the `RUN_SUMMARY` record in the key-value store carries `emptyReason` (`blocked` or `upstream_error`).

**How is this different from saving the HTML?** The Markdown keeps headings, lists, tables and code blocks of the article and drops everything around it. A typical news page goes from about 300 KB of HTML to 5 KB of Markdown.

**What does monitor mode compare?** The SHA-256 hash of the Markdown (`contentHash`). Layout changes, ads and timestamps outside the main content do not trigger a change.

### Changelog

- 0.1: initial release. URL list or crawl, main-content Markdown, metadata, links and images, proxy escalation, optional JS rendering, monitor mode, free rows for failed pages, private-address protection.

# Actor input Schema

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

Pages to convert, one per line, e.g. "https://docs.python.org/3/library/asyncio-task.html". With Crawl links on, these are the start pages. Private and internal addresses (localhost, 10.x, 169.254.x) are refused.

## `crawl` (type: `boolean`):

true = also follow links found on the pages (breadth-first) up to Max pages and Max depth. false = convert only the listed URLs.

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

Crawl budget: how many pages to fetch in total, start pages included, e.g. 50. Only used when Crawl links is on.

## `maxDepth` (type: `integer`):

How many clicks away from a start page the crawler may go, e.g. 2. 0 = start pages only.

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

true = follow only links on the start page's domain (www. ignored). false = follow links to any site.

## `includeUrlPatterns` (type: `array`):

Glob patterns a discovered link must match to be crawled, e.g. "*/docs/*". Empty = every link. Start URLs are always fetched.

## `excludeUrlPatterns` (type: `array`):

Glob patterns of links to skip, e.g. "*/blog/*" or "*?page=*".

## `renderJs` (type: `boolean`):

true = open pages in headless Chromium (for sites that build content with JavaScript). Slower; give the run 2048 MB memory. false = plain HTTP, fast and cheap.

## `waitFor` (type: `string`):

Only with Render JavaScript: CSS selector to wait for before reading the page, e.g. "article".

## `proxyTier` (type: `string`):

auto = start without a proxy and step up to datacenter, residential and Web Unblocker only when a page answers with a block or challenge. The working tier is remembered per domain.

## `proxyCountry` (type: `string`):

Optional two-letter country for proxy exits, e.g. "US" or "DE".

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

true = keep links inline in the Markdown and add a links list (absolute URL and anchor text) to each row.

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

true = keep images in the Markdown and add an images list (absolute URL and alt text) to each row.

## `domainDelaySecs` (type: `number`):

Minimum pause between two requests to the same domain, in seconds, e.g. 1.

## `timeout` (type: `integer`):

Give up on one page after this many seconds, e.g. 45.

## `maxItems` (type: `integer`):

Stop after this many successful pages (failed pages are free and do not count), e.g. 10.

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

scrape = full results; monitor = only new/changed items since the previous run of this task

## `monitorStateId` (type: `string`):

Optional state id when not running as a saved task (monitor mode)

## `webhookUrl` (type: `string`):

POST a change summary here in monitor mode

## `telegramBotToken` (type: `string`):

Optional: bot token for monitor-mode change summaries

## `telegramChatId` (type: `string`):

Optional: chat id that receives monitor-mode summaries

## Actor input object example

```json
{
  "urls": [
    "https://docs.python.org/3/library/asyncio-task.html"
  ],
  "crawl": false,
  "maxPages": 10,
  "maxDepth": 2,
  "sameDomainOnly": true,
  "renderJs": false,
  "proxyTier": "auto",
  "includeLinks": false,
  "includeImages": false,
  "domainDelaySecs": 1,
  "timeout": 45,
  "maxItems": 10,
  "mode": "scrape"
}
```

# Actor output Schema

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

All pushed rows (dataset, JSON)

## `resultsTable` (type: `string`):

Dataset in the Console viewer

## `runSummary` (type: `string`):

RUN_SUMMARY record

# 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://docs.python.org/3/library/asyncio-task.html"
    ],
    "maxItems": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("datahamster/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 = {
    "urls": ["https://docs.python.org/3/library/asyncio-task.html"],
    "maxItems": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("datahamster/website-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://docs.python.org/3/library/asyncio-task.html"
  ],
  "maxItems": 10
}' |
apify call datahamster/website-to-markdown --silent --output-dataset

```

## MCP server setup

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