# Website to Markdown for LLM & RAG + llms.txt Generator (`docflow-tools/website-to-markdown-llms-txt`) Actor

Turn websites into clean Markdown for LLMs, RAG and AI agents: main content only (no menus, footers, cookie banners), tables and links kept, optional RAG chunks, and a ready llms.txt + llms-full.txt per site. Respects robots.txt.

- **URL**: https://apify.com/docflow-tools/website-to-markdown-llms-txt.md
- **Developed by:** [DocFlow Tools](https://apify.com/docflow-tools) (community)
- **Categories:** AI, Agents, 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.20 / 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.
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 for LLM & RAG + llms.txt Generator

Turn websites into clean Markdown for LLMs, RAG pipelines and AI agents. The actor crawls the sites you give it
(same domain only, `robots.txt` respected), keeps the main content of each page with its headings, tables and links,
and drops menus, headers, footers, cookie banners and scripts. Optionally it splits each page into RAG chunks that are
never longer than your limit. At the end it writes an `llms.txt` index and an `llms-full.txt` file per site, in the
format proposed at [llmstxt.org](https://llmstxt.org). It uses no search engines and works over plain HTTP (no
browser). You pay only for pages converted.

### What you get

- **One dataset row per page:** URL, title, meta description, language, Markdown, word count, an estimated token
  count and, if you ask for them, chunks.
- **Main-content extraction** with [trafilatura](https://github.com/adbar/trafilatura) (links and tables kept, images
  and comments left out). If it finds fewer than 20 words, the actor falls back to the page's `<main>`, `<article>`
  or `<body>` with navigation, header, footer, aside, forms and scripts removed, converted with markdownify.
- **A `# heading` at the top** of the Markdown (the page's H1, or its title) when the page has a title and the
  extracted text does not already start with a heading.
- **RAG chunks** (optional): split at headings and paragraphs, never longer than `chunkSize`, with overlap.
- **`llms.txt` and `llms-full.txt` per site** in the key-value store.
- **Clean crawl:** same domain only (`www.` and the bare domain count as one site), `#fragments` and tracking
  parameters (`utm_*`, `gclid`, `fbclid`, `mc_cid`, `mc_eid`, `_hs*`, `ref`) removed, file links (PDF, images, CSS,
  JS, ZIP, Office documents and others) skipped, and two URLs that redirect to the same page delivered once.

### Use cases

- Load a documentation site or knowledge base into a vector database for RAG.
- Give an AI agent or chatbot the content of a website as Markdown.
- Generate a first `llms.txt` and `llms-full.txt` for your own site, then review and publish them at your domain
  root.
- Export a site's text for analysis, translation or migration.
- Convert only one section of a site with `includePatterns` (for example `/docs/`).

### How to use

1. Open the Actor in Apify Console and click **Try for free** / **Start**.
2. In **Websites or pages**, add one or more start URLs.
3. Set **Max pages** to the most pages you want to convert and pay for.
4. Optionally set **Only output URLs matching**, **Skip URLs matching**, **RAG chunk size** and **Chunk overlap**.
5. Run it. Pages are in the **Output** tab. The `llms-*.txt` files and the `SUMMARY` record are in the run's
   key-value store.

#### Input example

```json
{
  "startUrls": ["https://docs.example.com/"],
  "maxPages": 200,
  "crawlLinks": true,
  "includePatterns": ["/guides/", "/api/"],
  "excludePatterns": ["/changelog/"],
  "chunkSize": 2000,
  "chunkOverlap": 200,
  "generateLlmsTxt": true,
  "respectRobotsTxt": true
}
```

| Field | Type | Default | Meaning |
|---|---|---|---|
| `startUrls` | array of strings | required | Start pages. A URL without `https://` gets it added. |
| `maxPages` | integer (1-100,000) | 100 | Stop after this many converted pages in total. |
| `crawlLinks` | boolean | true | Follow internal links. Off = convert only the listed URLs. |
| `includePatterns` | array of regex | none | Only pages matching at least one pattern are output. Other pages are still crawled to find links, but not output or charged. Start URLs are always output. |
| `excludePatterns` | array of regex | none | Links matching any pattern are not crawled. |
| `chunkSize` | integer (0-100,000) | 0 | 0 = no chunks. Otherwise the maximum length of each chunk, in characters. |
| `chunkOverlap` | integer (0-5,000) | 200 | Characters from the end of one chunk repeated at the start of the next. |
| `generateLlmsTxt` | boolean | true | Write `llms-<site>.txt` and `llms-full-<site>.txt` to the key-value store. |
| `respectRobotsTxt` | boolean | true | Skip pages that `robots.txt` disallows. |

### Output example

One item per converted page (long values shortened):

```json
{
  "url": "https://docs.example.com/guides/install",
  "title": "Install | Example Docs",
  "description": "How to install Example on Linux, macOS and Windows.",
  "lang": "en",
  "markdown": "# Install\n\nExample runs on Linux, macOS and Windows...\n\n## Requirements\n\n| OS | Version |\n|---|---|\n| Linux | ...",
  "wordCount": 812,
  "tokensEstimate": 1290,
  "chunks": [
    "# Install\n\nExample runs on Linux, macOS and Windows...",
    "...last 200 characters of the previous chunk...\n\n## Requirements\n\n| OS | Version | ..."
  ]
}
```

- `description` comes from the meta description, or `og:description` if there is none.
- `tokensEstimate` is the Markdown length divided by 4, a rough estimate, not a tokenizer count.
- `chunks` is present only when `chunkSize` is above 0.
- `url` is the address the page ended on after redirects.

If no page is converted, the dataset gets one free item with `"status": "no_pages"` and the summary fields.

#### How chunks are built

- If the whole page fits in `chunkSize`, it is one chunk.
- Otherwise the Markdown is split before each heading and at blank lines. A block longer than `chunkSize` is cut at
  the last sentence end or line break that fits (if it is past half the limit), or else at exactly `chunkSize`.
- Blocks are joined while they fit. Each new chunk starts with the last `chunkOverlap` characters of the previous
  one, but only if that still fits; otherwise the chunk starts without overlap.
- No chunk is ever longer than `chunkSize`. The overlap is counted in characters, so it can start mid-word.

#### llms.txt and llms-full.txt

Converted pages are grouped by site (host without `www.`). For each site the key-value store gets two text files.
The key replaces every character other than letters, digits and `-` with `-`; for `docs.example.com` they are
`llms-docs-example-com.txt` and `llms-full-docs-example-com.txt`.

`llms-<site>.txt` follows the llmstxt.org structure: an H1 with the site name, a blockquote with the summary, and H2
sections with link lists. The name is the title of the site's home page (or of the first page converted, if the
home page was not), cut at the first `|` or `-`. The summary is that page's meta description. Sections are the
first folder of each URL path (`Main` for the root, listed first; the rest in alphabetical order). Each line is
`- [page title](url): description`.

```markdown
## Example Docs

> Guides and API reference for Example.

### Main

- [Example Docs | Example](https://docs.example.com/): Guides and API reference for Example.

### Api

- [Authentication - API | Example](https://docs.example.com/api/auth)

### Guides

- [Install | Example Docs](https://docs.example.com/guides/install): How to install Example on Linux, macOS and Windows.
```

`llms-full-<site>.txt` starts with the same H1 and then contains the Markdown of every page, each preceded by a
`<!-- source: url -->` line and separated by `---`.

The files list only the pages converted in that run, so set `maxPages` high enough to cover the site and review the
result before publishing it.

### Pricing

> **Prices by Apify discount tier:** the prices below are for the Bronze tier. **Free plan: 50 % off.** Silver: 10 % off. Gold and higher: 20 % off. Apify applies the right price automatically.

Pay per event, in USD:

| Event | Price | When |
|---|---|---|
| Actor start | $0.00005 | Charged by Apify when a run starts, per GB of run memory (default memory: 512 MB) |
| `page-converted` | $0.0015 | For each page written to the dataset. |

Not charged: pages that fail or return an HTTP error, pages blocked by `robots.txt`, non-HTML responses, a second
URL that redirects to a page already converted, pages crawled only to find links because they do not match
`includePatterns`, and the `no_pages` status item. The `llms.txt` files cost nothing extra.

**Control spend with `maxPages`.** The default is 100 pages; the maximum is 100,000. Only converted pages count
toward it. The run also stops cleanly if it reaches the maximum cost per run you set in Apify.

Examples:

- 100 pages: $0.00005 + 100 × $0.0015 = **$0.15005**
- 1,000 pages: $0.00005 + 1,000 × $0.0015 = **$1.50005**
- 300 pages crawled, 40 match `includePatterns`: $0.00005 + 40 × $0.0015 = **$0.06005**

### Use it from code, AI agents and integrations

**Apify API (one call, returns the dataset items):**

```bash
curl -X POST "https://api.apify.com/v2/acts/docflow-tools~website-to-markdown-llms-txt/run-sync-get-dataset-items?token=YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"startUrls": ["https://docs.example.com/"], "maxPages": 20, "chunkSize": 2000}'
```

Synchronous endpoints wait a limited time; for large crawls start the run asynchronously and read the results when
it finishes.

**Python (`apify-client`):**

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("docflow-tools/website-to-markdown-llms-txt").call(
    run_input={"startUrls": ["https://docs.example.com/"], "maxPages": 100, "chunkSize": 2000}
)
for page in client.dataset(run["defaultDatasetId"]).iterate_items():
    for chunk in page.get("chunks", []):
        ...  # embed and store the chunk with page["url"] as metadata

store = client.key_value_store(run["defaultKeyValueStoreId"])
llms_txt = store.get_record("llms-docs-example-com.txt")["value"]
```

**AI agents:** the Actor can be called by AI agents through the Apify MCP server at https://mcp.apify.com.

**No-code:** connect it to Make, Zapier, n8n and other tools through Apify integrations, or schedule it in Apify.

### Limits and notes

- **No JavaScript rendering.** Pages are fetched over HTTP. Content that only appears after JavaScript runs is not
  captured.
- Same domain only: links to other hosts or subdomains are not followed.
- `robots.txt` is respected by default (user agent token `LLMReadyBot`). If a site has no `robots.txt`, all pages
  are allowed.
- Only `http` and `https` URLs are fetched; domains that resolve to private, loopback, link-local or other internal
  addresses are blocked.
- `excludePatterns` apply to discovered links, not to the start URLs.
- Up to 5 pages are fetched in parallel, with a 30-second timeout per request. Only the first 5 MB of each page's
  HTML is used.
- Images are not included in the Markdown.
- The `SUMMARY` record lists pages converted, the first 200 errors, pages skipped by `robots.txt`, whether
  `maxPages` was reached and how many queued pages were not visited.

### FAQ

**Can I convert only some pages of a big site?**
Yes. Use `includePatterns` to choose what is output (and charged) and `excludePatterns` to stop the crawl from
entering sections you do not need. Or turn off `crawlLinks` and list the URLs.

**Is the generated llms.txt ready to publish?**
It follows the llmstxt.org structure and lists the pages converted in the run. Review the name, summary and sections
before you publish it at `https://your-site/llms.txt`.

**How large should chunks be?**
It depends on your embedding model and retrieval setup. `chunkSize` is in characters; `tokensEstimate` (characters
divided by 4) can help you pick a value.

**Do I pay for pages that fail?**
No. Failed pages are listed in `SUMMARY.errors` and are not charged.

**Does it use a search engine or visit other sites?**
No. It only visits the start URLs and links inside the same domain.

### Related tools

- [Document to Markdown for RAG](https://apify.com/docflow-tools/document-to-markdown-rag) — PDF, Word, Excel, PowerPoint and HTML files to Markdown with tables and RAG chunks; OCR for scanned pages.
- [RSS, Atom & JSON Feed Reader — only new items](https://apify.com/docflow-tools/feed-reader-only-new) — read feeds in one format and get only items you have not received before.
- [Bulk PageSpeed & Core Web Vitals](https://apify.com/docflow-tools/pagespeed-bulk-regression-monitor) — PageSpeed Insights for many URLs (your own free key), with alerts when pages get worse.
- [Image to Text OCR](https://apify.com/docflow-tools/image-ocr-own-engine) — text from images with each line, its position and confidence.
- [Audio & Video Transcriber](https://apify.com/docflow-tools/audio-transcriber-whisper-local) — Whisper running locally; text, timestamps, SRT and VTT.
- [Merge, Deduplicate & Convert Datasets](https://apify.com/docflow-tools/merge-dedupe-transform-data) — merge datasets and CSV/JSON/Excel files, remove duplicates, export to CSV or Excel.
- [Website Screenshot & Visual Change Monitor](https://apify.com/docflow-tools/website-screenshot-monitor) — bulk screenshots (PNG, JPEG, PDF) with optional change detection.
- [Bulk Image Converter & Compressor](https://apify.com/docflow-tools/bulk-image-converter-compressor) — convert, compress and resize images to WebP, AVIF, JPEG or PNG.
- [Sitemap URL Extractor](https://apify.com/docflow-tools/sitemap-url-extractor-reliable) — every URL from a site's sitemaps, with lastmod, images and hreflang.
- [SEO Audit Crawler](https://apify.com/docflow-tools/seo-audit-crawler-cheap) — 0-100 on-page SEO score per page, each issue with severity and fix.

# Actor input Schema

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

Start URLs. With 'Follow internal links' on, the crawl continues inside the same domain.

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

Stop after this many converted pages in total. You pay only for pages converted.

## `crawlLinks` (type: `boolean`):

Off = convert only the URLs you list.

## `includePatterns` (type: `array`):

Regular expressions (e.g. /docs/). Other pages are still crawled to find links, but not output or charged.

## `excludePatterns` (type: `array`):

Regular expressions for URLs not to crawl.

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

0 = no chunks. Otherwise split each page by headings and paragraphs into chunks no longer than this.

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

Characters repeated from the end of one chunk at the start of the next.

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

Save llms-<site>.txt (index of pages, llmstxt.org format) and llms-full-<site>.txt (all Markdown) in the key-value store.

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

Skip pages that robots.txt disallows (recommended).

## Actor input object example

```json
{
  "startUrls": [
    "https://docs.apify.com/platform/actors"
  ],
  "maxPages": 5,
  "crawlLinks": true,
  "chunkSize": 0,
  "chunkOverlap": 200,
  "generateLlmsTxt": true,
  "respectRobotsTxt": true
}
```

# Actor output Schema

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

No description

## `files` (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 = {
    "startUrls": [
        "https://docs.apify.com/platform/actors"
    ],
    "maxPages": 5
};

// Run the Actor and wait for it to finish
const run = await client.actor("docflow-tools/website-to-markdown-llms-txt").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/platform/actors"],
    "maxPages": 5,
}

# Run the Actor and wait for it to finish
run = client.actor("docflow-tools/website-to-markdown-llms-txt").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/platform/actors"
  ],
  "maxPages": 5
}' |
apify call docflow-tools/website-to-markdown-llms-txt --silent --output-dataset

```

## MCP server setup

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

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/BKYk3Kbtmw20OwzCT/builds/2dTGeVNwuSoxPZLnr/openapi.json
