# Website & URL to Markdown Crawler + llms.txt Generator (`api-co/website-to-markdown`) Actor

Crawl websites or URL lists into clean Markdown for LLMs, RAG and AI agents: URL to Markdown, docs to Markdown, HTML to Markdown with main-content extraction, metadata and chunks. Includes an llms.txt generator for any site.

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

## Pricing

from $0.80 / 1,000 pages

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
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 & URL to Markdown Crawler + llms.txt Generator

Crawl a website, or convert a list of URLs, into **clean Markdown for LLMs, RAG, AI agents and fine-tuning datasets**. It keeps the main content (navigation, ads, cookie banners and footers are removed), plus headings, tables, code blocks and links. You also get metadata, token counts, optional RAG chunks and a ready-made **llms.txt / llms-full.txt**.

It's an HTTP crawler with no headless browser, so it's **fast and cheap**: about 10 pages/second on documentation sites.

### How to use

1. Enter one or more **start URLs** (a docs site, blog or any website).
2. Choose *crawl* (follow links) or *list* (only the given URLs), and set *Max pages*.
3. Click **Start** and download clean Markdown for every page, plus an `llms.txt` file.

### Features

- **Main-content extraction** with Mozilla Readability and a boilerplate-removal fallback, or full-page mode.
- **GitHub-flavored Markdown**: tables, fenced code blocks with language, lists, absolute links, and optional images.
- **Crawl control**: depth, max pages, include/exclude globs or regex, subdomains, **sitemap.xml seeding** and **robots.txt** compliance.
- **De-duplication**: redirects, canonical URLs and identical content are skipped and not charged.
- **Metadata**: title, description, canonical, language, author, published/modified dates, og:image, site name, headings outline, word count and token estimate.
- **RAG chunks** split on headings and paragraphs, with heading path, token counts and overlap.
- **llms.txt + llms-full.txt** saved to the key-value store for free, ready to drop on your site or feed to an agent.
- `possiblyJsRendered` flag for pages that need a browser.

### Why this Actor

| | This Actor | Typical website-to-Markdown Actors |
|---|---|---|
| Price | **$1 / 1,000 pages**, no start fee | $2.30 to $3 / 1,000 + start fees |
| llms.txt generation | **Yes** (free) | No |
| RAG chunks with heading path | **Yes** | Rarely |
| Sitemap seeding + robots.txt | **Yes** | Varies |
| Duplicates/redirects charged | **No** | Often yes |

### Input example

```json
{ "startUrls": ["https://docs.example.com/"], "maxPages": 500, "includeUrlPatterns": ["https://docs.example.com/**"], "useSitemap": true, "chunking": true }
```

### Output

````json
{ "url": "https://docs.example.com/getting-started", "title": "Getting started", "description": "...", "canonical": "...", "language": "en",
  "markdown": "# Getting started\n\nInstall the SDK...\n\n```bash\nnpm i example\n```", "headings": [{ "level": 2, "text": "Install" }],
  "wordCount": 812, "tokensEstimate": 1350, "depth": 1, "statusCode": 200, "extraction": "readability",
  "chunks": [{ "index": 0, "text": "...", "headingPath": "Getting started > Install", "tokens": 640, "url": "..." }] }
````

Key-value store: `llms.txt` (index of pages with titles and descriptions) and `llms-full.txt` (all page Markdown).

### Pricing (pay per event)

**$0.001 per page** ($1 per 1,000 pages). Failed fetches, non-HTML files, duplicates and pages below *Min words* are free.

### How much does it cost?

You only pay for results, never for compute time:

| You get | You pay (Starter/Bronze plan price) |
|---|---|
| 100 pages | $0.10 |
| 1,000 pages | $1.00 |
| 10,000 pages | $10.00 |

Apify's **free plan includes $5 of usage every month**, and free-plan users pay **half price** on this Actor, so that covers about **10,000 pages** at no cost. Paid plans get volume discounts (Silver -10%, Gold -20%). Set a *maximum cost per run* and the Actor stops cleanly at your limit.

### Notes

- Respect each site's terms. robots.txt is honored by default, and each host is limited to 5 requests/second.
- Sites that render content only with JavaScript (empty HTML) are flagged `possiblyJsRendered`. Use a browser-based crawler for those.

### Run it from code (API, Python, JavaScript)

```bash
curl -X POST "https://api.apify.com/v2/acts/api-co~website-to-markdown/run-sync-get-dataset-items?token=YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" -d '{"startUrls": ["https://docs.apify.com/academy/web-scraping-for-beginners"], "maxItems": 50}'
```

```python
from apify_client import ApifyClient
client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("api-co/website-to-markdown").call(run_input={"startUrls": ["https://docs.apify.com/academy/web-scraping-for-beginners"], "maxItems": 50})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)
```

```javascript
import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: 'YOUR_APIFY_TOKEN' });
const run = await client.actor('api-co/website-to-markdown').call({"startUrls": ["https://docs.apify.com/academy/web-scraping-for-beginners"], "maxItems": 50});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
```

It also works from **AI agents through the Apify MCP server**, and with Zapier, Make, n8n, Google Sheets and webhooks. You can schedule it in the Apify Console.

### FAQ

**How is this different from Website Content Crawler?**
It's a lightweight HTTP crawler focused on docs and content sites. It's fast and cheap ($1 per 1,000 pages), and it generates llms.txt / llms-full.txt for free. For JavaScript-heavy apps that need a real browser, use a browser-based crawler.

**Does it respect robots.txt?**
Yes. It's sitemap-aware and robots.txt-aware.

**What do I get per page?**
Clean main-content Markdown (no nav or footer), title, description, headings, tables and code blocks, token count and RAG chunks.

**Can I feed it straight into a vector database?**
Yes. Use the chunks field, or connect the dataset to LangChain, LlamaIndex, Pinecone or Qdrant through Apify integrations.

### Use cases

- **RAG chatbots**: turn a documentation site into Markdown chunks for your vector database.
- **llms.txt generation**: create an `llms.txt` for your own site so AI assistants can read it.
- **AI agents**: give an agent clean page content instead of raw HTML.
- **Content audits and migrations**: export a whole site's text with titles, headings and metadata.

# Actor input Schema

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

Pages or sites to convert, e.g. https://docs.example.com/. In crawl mode, links are followed from here.

## `urlsText` (type: `string`):

Paste many URLs, one per line.

## `crawlMode` (type: `string`):

crawl = follow links on the same site. single = convert only the URLs you list.

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

Maximum pages to fetch (also caps the results you pay for).

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

How many clicks away from the start URL to follow.

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

Only follow URLs matching these globs (\*\* = anything, \* = one path segment) or /regex/, e.g. https://example.com/docs/\*\*

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

Skip URLs matching these globs or /regex/, e.g. **/tag/**, \**?page=*

## `useSitemap` (type: `boolean`):

Seed the crawl from robots.txt sitemaps and /sitemap.xml, so large sites get full coverage.

## `includeSubdomains` (type: `boolean`):

Also follow links to subdomains of the start host (e.g. blog.example.com).

## `respectRobots` (type: `boolean`):

Skip pages disallowed by robots.txt (recommended; only disable for sites you own).

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

auto = main content only (Readability, with boilerplate removal fallback). full = the whole page body.

## `removeSelectors` (type: `array`):

Extra elements to strip before conversion, e.g. .sidebar, #comments.

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

Keep hyperlinks as Markdown links (absolute URLs).

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

Keep images as Markdown image tags (absolute URLs).

## `includeText` (type: `boolean`):

Also return plain text.

## `includeHtml` (type: `boolean`):

Also return the raw HTML (up to 500 KB per page).

## `minWords` (type: `integer`):

Skip pages with fewer words (they aren't charged).

## `chunking` (type: `boolean`):

Add a 'chunks' array split on headings and paragraphs with heading path and token estimates.

## `chunkTokens` (type: `integer`):

Target chunk size in tokens (about 4 characters per token).

## `chunkOverlapTokens` (type: `integer`):

Approximate overlap between consecutive chunks.

## `generateLlmsTxt` (type: `boolean`):

Save llms.txt (page index) and llms-full.txt (all content) to the run's key-value store, free.

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

Parallel requests (each host is also capped at 5 requests/second).

## Actor input object example

```json
{
  "startUrls": [
    "https://docs.apify.com/academy/web-scraping-for-beginners"
  ],
  "crawlMode": "crawl",
  "maxPages": 10,
  "maxDepth": 3,
  "useSitemap": false,
  "includeSubdomains": false,
  "respectRobots": true,
  "contentMode": "auto",
  "includeLinks": true,
  "includeImages": false,
  "includeText": false,
  "includeHtml": false,
  "minWords": 0,
  "chunking": false,
  "chunkTokens": 800,
  "chunkOverlapTokens": 100,
  "generateLlmsTxt": true,
  "maxConcurrency": 10
}
```

# Actor output Schema

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

One item per crawled page with clean Markdown, metadata and optional RAG chunks.

## `llmsTxt` (type: `string`):

All crawled pages concatenated as one Markdown file (when generateLlmsTxt is on).

# 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://docs.apify.com/academy/web-scraping-for-beginners"
    ],
    "maxPages": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("api-co/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://docs.apify.com/academy/web-scraping-for-beginners"],
    "maxPages": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("api-co/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 '{
  "startUrls": [
    "https://docs.apify.com/academy/web-scraping-for-beginners"
  ],
  "maxPages": 10
}' |
apify call api-co/website-to-markdown --silent --output-dataset

```

## MCP server setup

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