# Website to RAG Markdown Crawler (`knotted_tussock/rag-markdown-crawler`) Actor

Crawl any website or docs site and export clean Markdown plus JSONL-style chunks for RAG, LLM apps, and AI agents.

- **URL**: https://apify.com/knotted\_tussock/rag-markdown-crawler.md
- **Developed by:** [Ralph T](https://apify.com/knotted_tussock) (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.50 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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 RAG Markdown Crawler

Crawl any website, documentation site, blog, or sitemap and export clean Markdown plus JSONL-style chunks for RAG, LLM apps, AI agents, and vector database pipelines.

### What it does

- Starts from one or more web pages or `sitemap.xml` URLs.
- Expands sitemap indexes and sitemap URL sets into crawlable page URLs.
- Follows same-domain links up to a configurable depth.
- Removes navigation/footer/script/style noise.
- Converts HTML to clean Markdown.
- Emits both full-page records and smaller RAG chunk records.
- Adds estimated token counts for pages and chunks.
- Includes source URL, title, description, timestamps, character counts, token estimates, and chunk metadata.

### Best for

- Preparing documentation sites for RAG.
- Building AI chatbot or AI support-bot knowledge bases.
- Creating clean Markdown from help centers, blogs, changelogs, and product docs.
- Turning competitor docs/blogs into structured internal research data.
- Feeding LangChain, LlamaIndex, Supabase, Chroma, Pinecone, Qdrant, or custom vector pipelines.

### Input example

```json
{
  "startUrls": [{ "url": "https://docs.apify.com/sitemap.xml" }],
  "maxPages": 25,
  "maxDepth": 1,
  "expandSitemaps": true,
  "maxSitemapUrls": 5000,
  "includePatterns": ["^https://docs\\.apify\\.com/platform/actors"],
  "excludePatterns": ["/login", "/signup", "#"],
  "removeSelectors": ["nav", "footer", "script", "style", "noscript", "svg"],
  "chunkSize": 1200,
  "chunkOverlap": 150,
  "sameDomainOnly": true,
  "includePageRecords": true
}
````

### Output records

The Actor defines Apify dataset/output schemas so the Output tab has dedicated views for RAG chunks, full pages, and metadata. The default dataset contains two record types by default.

#### `page`

Full-page Markdown record:

```json
{
  "recordType": "page",
  "url": "https://example.com/",
  "requestedUrl": "https://example.com/",
  "title": "Example Domain",
  "description": "",
  "source": "sitemap",
  "sitemapUrl": "https://example.com/sitemap.xml",
  "markdown": "# Example Domain...",
  "charCount": 167,
  "estimatedTokenCount": 42,
  "tokenCountMethod": "approx_chars_per_4",
  "chunkCount": 1,
  "crawledAt": "2026-07-04T00:00:00.000Z"
}
```

#### `chunk`

RAG-ready chunk record:

```json
{
  "recordType": "chunk",
  "url": "https://example.com/",
  "title": "Example Domain",
  "chunkIndex": 0,
  "chunkCount": 1,
  "text": "# Example Domain...",
  "charCount": 167,
  "estimatedTokenCount": 42,
  "tokenCountMethod": "approx_chars_per_4",
  "metadata": {
    "source": "https://example.com/",
    "title": "Example Domain",
    "crawledAt": "2026-07-04T00:00:00.000Z",
    "sourceType": "sitemap",
    "sitemapUrl": "https://example.com/sitemap.xml"
  }
}
```

### Sitemap support

If a start URL looks like a sitemap, for example `https://example.com/sitemap.xml`, the Actor extracts URLs from `<loc>` entries and crawls the matching pages. Sitemap indexes are followed recursively. Use `includePatterns` and `excludePatterns` to focus large sitemaps before crawling.

### Token counts

The Actor includes an `estimatedTokenCount` field for each page and chunk using a fast `approx_chars_per_4` method. This is useful for budgeting embedding jobs and sizing RAG chunks. Treat it as an estimate rather than an exact model-specific tokenizer count.

### Example workflow

1. Enter a website URL or sitemap URL.
2. Set `maxPages` and `maxDepth` to control crawl size.
3. Use `includePatterns` / `excludePatterns` to keep the crawl focused.
4. Run the Actor.
5. Export `chunk` records as JSON/JSONL.
6. Load those chunks into your vector database or RAG pipeline.

### Notes

- This Actor is optimized for regular HTML pages, blogs, documentation sites, and help centers.
- JavaScript-heavy single-page apps may need a browser-based crawler variant.
- Keep `maxPages` low for first runs, inspect output, then scale up.
- Disable `includePageRecords` if you only want chunk records for embedding.

# Actor input Schema

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

Website pages or sitemap XML URLs to crawl. Sitemap URLs are expanded when Expand sitemaps is enabled.

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

Maximum number of HTML pages to crawl after sitemap expansion and link discovery.

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

How far to follow same-domain links from non-sitemap start URLs. Sitemap-expanded URLs start at depth 0.

## `expandSitemaps` (type: `boolean`):

When a start URL looks like a sitemap XML file, extract page URLs from it and crawl those pages.

## `maxSitemapUrls` (type: `integer`):

Maximum number of URLs to read from sitemaps before maxPages is applied.

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

Optional regex patterns. If set, only matching URLs are crawled.

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

Regex patterns for URLs to skip.

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

Elements to remove before markdown conversion.

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

Approximate markdown characters per RAG chunk. Set 0 to disable chunks.

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

Approximate overlapping characters between chunks.

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

Only follow links on the same hostname as the current page or sitemap.

## `includePageRecords` (type: `boolean`):

Include full-page markdown records in addition to chunk records. Disable if you only want RAG chunks.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://docs.apify.com/sitemap.xml"
    }
  ],
  "maxPages": 25,
  "maxDepth": 1,
  "expandSitemaps": true,
  "maxSitemapUrls": 5000,
  "includePatterns": [],
  "excludePatterns": [
    "/login",
    "/signup",
    "#"
  ],
  "removeSelectors": [
    "nav",
    "footer",
    "script",
    "style",
    "noscript",
    "svg"
  ],
  "chunkSize": 1200,
  "chunkOverlap": 150,
  "sameDomainOnly": true,
  "includePageRecords": true
}
```

# Actor output Schema

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

All page and chunk records in the default dataset. Use the dataset views to inspect RAG chunks, full pages, or metadata.

## `ragChunks` (type: `string`):

Default dataset opened with the RAG chunks view selected for embedding/vector database workflows.

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

Summary JSON containing pages saved, chunks saved, estimated token count, and sitemap queue counts.

# 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": [
        {
            "url": "https://docs.apify.com/sitemap.xml"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("knotted_tussock/rag-markdown-crawler").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": [{ "url": "https://docs.apify.com/sitemap.xml" }] }

# Run the Actor and wait for it to finish
run = client.actor("knotted_tussock/rag-markdown-crawler").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": [
    {
      "url": "https://docs.apify.com/sitemap.xml"
    }
  ]
}' |
apify call knotted_tussock/rag-markdown-crawler --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Website to RAG Markdown Crawler",
        "description": "Crawl any website or docs site and export clean Markdown plus JSONL-style chunks for RAG, LLM apps, and AI agents.",
        "version": "0.1",
        "x-build-id": "69p623bYF3DFeMha7"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/knotted_tussock~rag-markdown-crawler/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-knotted_tussock-rag-markdown-crawler",
                "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/knotted_tussock~rag-markdown-crawler/runs": {
            "post": {
                "operationId": "runs-sync-knotted_tussock-rag-markdown-crawler",
                "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/knotted_tussock~rag-markdown-crawler/run-sync": {
            "post": {
                "operationId": "run-sync-knotted_tussock-rag-markdown-crawler",
                "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",
                "required": [
                    "startUrls"
                ],
                "properties": {
                    "startUrls": {
                        "title": "Start URLs or sitemap URLs",
                        "type": "array",
                        "description": "Website pages or sitemap XML URLs to crawl. Sitemap URLs are expanded when Expand sitemaps is enabled.",
                        "items": {
                            "type": "object",
                            "required": [
                                "url"
                            ],
                            "properties": {
                                "url": {
                                    "type": "string",
                                    "title": "URL of a web page",
                                    "format": "uri"
                                }
                            }
                        }
                    },
                    "maxPages": {
                        "title": "Maximum pages",
                        "minimum": 1,
                        "maximum": 10000,
                        "type": "integer",
                        "description": "Maximum number of HTML pages to crawl after sitemap expansion and link discovery.",
                        "default": 25
                    },
                    "maxDepth": {
                        "title": "Maximum link depth",
                        "minimum": 0,
                        "maximum": 20,
                        "type": "integer",
                        "description": "How far to follow same-domain links from non-sitemap start URLs. Sitemap-expanded URLs start at depth 0.",
                        "default": 1
                    },
                    "expandSitemaps": {
                        "title": "Expand sitemaps",
                        "type": "boolean",
                        "description": "When a start URL looks like a sitemap XML file, extract page URLs from it and crawl those pages.",
                        "default": true
                    },
                    "maxSitemapUrls": {
                        "title": "Maximum sitemap URLs",
                        "minimum": 1,
                        "maximum": 50000,
                        "type": "integer",
                        "description": "Maximum number of URLs to read from sitemaps before maxPages is applied.",
                        "default": 5000
                    },
                    "includePatterns": {
                        "title": "Include URL patterns",
                        "type": "array",
                        "description": "Optional regex patterns. If set, only matching URLs are crawled.",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    },
                    "excludePatterns": {
                        "title": "Exclude URL patterns",
                        "type": "array",
                        "description": "Regex patterns for URLs to skip.",
                        "default": [
                            "/login",
                            "/signup",
                            "#"
                        ],
                        "items": {
                            "type": "string"
                        }
                    },
                    "removeSelectors": {
                        "title": "Remove CSS selectors",
                        "type": "array",
                        "description": "Elements to remove before markdown conversion.",
                        "default": [
                            "nav",
                            "footer",
                            "script",
                            "style",
                            "noscript",
                            "svg"
                        ],
                        "items": {
                            "type": "string"
                        }
                    },
                    "chunkSize": {
                        "title": "Chunk size",
                        "minimum": 0,
                        "maximum": 20000,
                        "type": "integer",
                        "description": "Approximate markdown characters per RAG chunk. Set 0 to disable chunks.",
                        "default": 1200
                    },
                    "chunkOverlap": {
                        "title": "Chunk overlap",
                        "minimum": 0,
                        "maximum": 5000,
                        "type": "integer",
                        "description": "Approximate overlapping characters between chunks.",
                        "default": 150
                    },
                    "sameDomainOnly": {
                        "title": "Same domain only",
                        "type": "boolean",
                        "description": "Only follow links on the same hostname as the current page or sitemap.",
                        "default": true
                    },
                    "includePageRecords": {
                        "title": "Include full-page records",
                        "type": "boolean",
                        "description": "Include full-page markdown records in addition to chunk records. Disable if you only want RAG chunks.",
                        "default": true
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
