# Website to Markdown Crawler: Docs, Sitemaps & LLM RAG (`salmon_chaparral/website-markdown-rag-crawler`) Actor

Website to Markdown crawler & Website Content Crawler: crawl websites, docs, llms.txt & sitemap.xml into clean text, GitHub-Flavored Markdown, metadata & RAG chunks for LLMs and vector databases — no browser or API key. Export JSON/CSV. $0 start, $1/1K pages; failed pages free.

- **URL**: https://apify.com/salmon_chaparral/website-markdown-rag-crawler.md
- **Developed by:** [Max Lee](https://apify.com/salmon_chaparral) (community)
- **Categories:** AI, Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 1,000 crawled webpage to markdown & rag chunks

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/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 & Docs to Markdown Crawler for LLM RAG

Fast pure-HTTP website and documentation crawler at 256MB RAM with zero headless browser overhead and no API key required. Click **Start** with default inputs to immediately discover public technical documentation via `llms.txt`, `sitemap.xml`, and same-origin HTML links, convert HTML into clean GitHub-Flavored Markdown, extract page metadata and heading outlines, and split content into overlapping LLM RAG chunks.

### Features

- **Multi-source URL discovery**: Automatically discovers pages from `llms.txt` Markdown link indexes, `sitemap.xml` / sitemap indexes, and recursive same-origin HTML links up to `maxDepth`, with optional `samePathPrefixOnly`, `includeUrlPatterns`, and `excludeUrlPatterns` filters.
- **Clean HTML-to-Markdown conversion**: Strips `<script>`, `<style>`, `<noscript>`, `<svg>`, `<iframe>`, `<nav>`, `<header>`, `<footer>`, and `<aside>` boilerplate, prefers `<main>` / `<article>` when `mainContentOnly` is enabled, and preserves headings, inline formatting, links, images, lists, blockquotes, fenced code blocks with language tags, and GitHub-Flavored Markdown tables.
- **Metadata & headings extraction**: Extracts `title`, `metaDescription`, `canonicalUrl`, `language`, `author`, `publishedAt`, `headingsCount`, `headingsOutline`, structured `headings[]`, and internal/external link counts.
- **Configurable LLM RAG chunking**: Splits Markdown along heading and paragraph boundaries with configurable `chunkMaxChars`, optional `chunkMaxTokens` (~4 chars/token) override, and `chunkOverlapChars` overlap. Each chunk includes `index`, `heading`, `charStart`, `charEnd`, `charCount`, `wordCount`, `estimatedTokens`, and `text`.
- **SSRF-hardened pure HTTP**: Blocks private, loopback, link-local, CGNAT, and cloud metadata IPv4/IPv6 targets (with DNS resolution checks and per-hop manual redirect validation), enforces per-request timeouts, and caps streaming response bytes.

### Input Example

```json
{
  "startUrls": [
    "https://modelcontextprotocol.io/llms.txt",
    "https://docs.python.org/3/tutorial/introduction.html"
  ],
  "discoverLlmsTxt": true,
  "discoverSitemap": true,
  "crawlLinks": true,
  "maxPages": 10,
  "maxDepth": 1,
  "mainContentOnly": true,
  "includeChunks": true,
  "chunkMaxChars": 1500,
  "chunkMaxTokens": 0,
  "chunkOverlapChars": 200
}
```

Pass any public documentation root, direct `sitemap.xml`, `llms.txt`, or list of article URLs into `startUrls`. Set `chunkMaxTokens` (for example `400`) to size chunks by estimated token count instead of characters.

### Output Fields

Every dataset item shares a flat table-ready schema plus structured `headings` and `chunks` arrays in JSON export:

- `url`, `canonicalUrl`, `domain`, `path`, `discoverySource` (`seed` | `llms_txt` | `sitemap` | `link`), `depth`
- `httpStatus`, `contentType`, `contentFormat` (`html` | `markdown` | `text`)
- `title`, `metaDescription`, `language`, `author`, `publishedAt`
- `headingsCount`, `headingsOutline`, `headings`
- `markdown`, `charCount`, `wordCount`, `estimatedTokens`, `truncated`
- `chunkCount`, `chunks` (array of `{ index, heading, charStart, charEnd, charCount, wordCount, estimatedTokens, text }`)
- `internalLinksCount`, `externalLinksCount`, `crawledAt`

### Pricing

Pay-Per-Event: **$0 start fee**, **$0.001 per crawled page** (`$1.00 / 1,000 pages`). Failed HTTP fetches, timeouts, empty pages, and SSRF-blocked URLs are never charged.

# Changelog

This Actor's version history is a separate document: https://apify.com/salmon_chaparral/website-markdown-rag-crawler/changelog.md

# Actor input Schema

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

Public HTTP(S) page URLs, documentation roots, sitemap.xml URLs, or llms.txt URLs to crawl.

## `discoverLlmsTxt` (type: `boolean`):

Automatically probe /llms.txt on each seed origin and parse Markdown link indexes when a start URL points to llms.txt.

## `discoverSitemap` (type: `boolean`):

Automatically probe /sitemap.xml on each seed origin (and parse direct sitemap XML URLs) to enqueue same-origin pages.

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

Recursively follow same-origin HTML hyperlinks up to maxDepth.

## `samePathPrefixOnly` (type: `boolean`):

When enabled, discovered links and sitemap URLs are restricted to the parent path prefix of each seed URL (ignored for root or llms.txt/sitemap.xml seeds).

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

Optional substrings or simple \* wildcard patterns that discovered URLs must match (e.g. "/docs/\*", "/guides/").

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

Optional substrings or \* wildcard patterns to skip during discovery (e.g. "/changelog\*", "/blog/\*").

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

Hard cap on successfully crawled pages pushed to the dataset (1-500).

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

Maximum link traversal depth from seed URLs (0 = seeds only, up to 5).

## `mainContentOnly` (type: `boolean`):

Prefer <main> or <article> containers and strip nav, header, footer, aside, script, and style boilerplate.

## `includeChunks` (type: `boolean`):

Split each page's clean Markdown into heading-aware overlapping chunks for vector databases and LLM retrieval.

## `chunkMaxChars` (type: `integer`):

Target maximum character length per RAG chunk when chunkMaxTokens is 0 (200-12000).

## `chunkMaxTokens` (type: `integer`):

Optional approximate token budget per RAG chunk (0 = use chunkMaxChars; when > 0 uses ~4 chars/token up to 4000 tokens).

## `chunkOverlapChars` (type: `integer`):

Character overlap preserved between adjacent RAG chunks (0-2000).

## `maxMarkdownChars` (type: `integer`):

Truncate individual page Markdown above this character cap to keep dataset items compact (1000-200000).

## `concurrency` (type: `integer`):

Maximum concurrent pure-HTTP fetches (1-10).

## `requestTimeoutSecs` (type: `integer`):

Per-HTTP request timeout in seconds (3-30).

## `maxResponseSizeKb` (type: `integer`):

Streaming per-response byte cap in kilobytes (64-4096).

## Actor input object example

```json
{
  "startUrls": [
    "https://modelcontextprotocol.io/llms.txt",
    "https://docs.python.org/3/tutorial/introduction.html"
  ],
  "discoverLlmsTxt": true,
  "discoverSitemap": true,
  "crawlLinks": true,
  "samePathPrefixOnly": false,
  "includeUrlPatterns": [],
  "excludeUrlPatterns": [],
  "maxPages": 10,
  "maxDepth": 1,
  "mainContentOnly": true,
  "includeChunks": true,
  "chunkMaxChars": 1500,
  "chunkMaxTokens": 0,
  "chunkOverlapChars": 200,
  "maxMarkdownChars": 50000,
  "concurrency": 4,
  "requestTimeoutSecs": 12,
  "maxResponseSizeKb": 1024
}
```

# Actor output Schema

## `pages` (type: `string`):

No description

## `summary` (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://modelcontextprotocol.io/llms.txt",
        "https://docs.python.org/3/tutorial/introduction.html"
    ],
    "discoverLlmsTxt": true,
    "discoverSitemap": true,
    "crawlLinks": true,
    "samePathPrefixOnly": false,
    "includeUrlPatterns": [],
    "excludeUrlPatterns": [],
    "maxPages": 10,
    "maxDepth": 1,
    "mainContentOnly": true,
    "includeChunks": true,
    "chunkMaxChars": 1500,
    "chunkMaxTokens": 0,
    "chunkOverlapChars": 200,
    "maxMarkdownChars": 50000,
    "concurrency": 4,
    "requestTimeoutSecs": 12,
    "maxResponseSizeKb": 1024
};

// Run the Actor and wait for it to finish
const run = await client.actor("salmon_chaparral/website-markdown-rag-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": [
        "https://modelcontextprotocol.io/llms.txt",
        "https://docs.python.org/3/tutorial/introduction.html",
    ],
    "discoverLlmsTxt": True,
    "discoverSitemap": True,
    "crawlLinks": True,
    "samePathPrefixOnly": False,
    "includeUrlPatterns": [],
    "excludeUrlPatterns": [],
    "maxPages": 10,
    "maxDepth": 1,
    "mainContentOnly": True,
    "includeChunks": True,
    "chunkMaxChars": 1500,
    "chunkMaxTokens": 0,
    "chunkOverlapChars": 200,
    "maxMarkdownChars": 50000,
    "concurrency": 4,
    "requestTimeoutSecs": 12,
    "maxResponseSizeKb": 1024,
}

# Run the Actor and wait for it to finish
run = client.actor("salmon_chaparral/website-markdown-rag-crawler").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://modelcontextprotocol.io/llms.txt",
    "https://docs.python.org/3/tutorial/introduction.html"
  ],
  "discoverLlmsTxt": true,
  "discoverSitemap": true,
  "crawlLinks": true,
  "samePathPrefixOnly": false,
  "includeUrlPatterns": [],
  "excludeUrlPatterns": [],
  "maxPages": 10,
  "maxDepth": 1,
  "mainContentOnly": true,
  "includeChunks": true,
  "chunkMaxChars": 1500,
  "chunkMaxTokens": 0,
  "chunkOverlapChars": 200,
  "maxMarkdownChars": 50000,
  "concurrency": 4,
  "requestTimeoutSecs": 12,
  "maxResponseSizeKb": 1024
}' |
apify call salmon_chaparral/website-markdown-rag-crawler --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,salmon_chaparral/website-markdown-rag-crawler"
        }
    }
}
```

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/7IAeONVOMutndReP6/builds/gjeowMFfUgdiz2G0Q/openapi.json
