# Sitemap Scraper - Crawl Sitemap URLs to Markdown for RAG (`bin_ai_tools/sitemap-to-markdown`) Actor

Convert every page in a website or sitemap to clean Markdown for LLMs, RAG and llms.txt. 1 converted page = 1 event. Failed pages are never charged.

- **URL**: https://apify.com/bin_ai_tools/sitemap-to-markdown.md
- **Developed by:** [Bin Bin](https://apify.com/bin_ai_tools) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## Sitemap to Markdown Crawler — Bulk Website Pages for LLM & RAG

Turn a whole website — or one sitemap — into clean, per-page Markdown ready for LLM context,
RAG ingestion, fine-tuning datasets or an `llms.txt` file. Point it at a site or a sitemap,
set how many pages you want, and get one dataset row per page.

Pay per converted page: $0.002 per page (plus a $0.00005 run start). Failed pages are not charged.

Only have a list of URLs, not a whole site? Use [AI Web Crawler](https://apify.com/bin_ai_tools/ai-web-crawler) instead — same Markdown output, no sitemap discovery.

### What it does

- Discovers pages from `robots.txt` Sitemap lines, `/sitemap.xml`, `/sitemap_index.xml`,
  nested sitemap indexes and gzipped `.xml.gz` sitemaps; falls back to start-page links.
- Converts each page's main content to Markdown: headings, lists, bold/italic, inline code,
  fenced code blocks, absolute links. Strips nav, header, footer, forms, scripts and styles.
- Optional: builds `llms.txt` and `llms-full.txt` from the same run, **at no extra charge**.
- Respects `robots.txt` by default.

### Transparent pricing

- **$0.002 per successfully converted page.** That is the only event this Actor charges.
- **Failed pages cost $0.** 404s, timeouts, non-HTML files, robots-blocked or JS-only pages
  are written as `type: "error"` rows with the reason, and never billed.
- **No format multipliers.** Adding llms.txt / llms-full.txt does not change the price.
- **Your budget is respected.** If you set a maximum charge per run, the Actor stops
  cleanly when it is reached and tells you how many pages were left unprocessed (and unbilled).

| Pages converted | Cost |
|-----------------|------|
| 100             | $0.20 |
| 500             | $1.00 |

### Input

| Field          | Default | Notes |
|----------------|---------|-------|
| siteUrl        | —       | Website start URL. Use this **or** sitemapUrl. |
| sitemapUrl     | —       | Direct sitemap / sitemap index / .xml.gz. Wins if both are set. |
| maxPages       | 100     | Cap 500. Larger values are capped with a notice, never rejected. |
| outputMode     | pages   | `pages` or `pages_and_llmstxt` |
| respectRobots  | true    | Skip pages disallowed for this crawler (not billed). |
| concurrency    | 5       | 1–10 parallel fetches. |

### Output

Dataset — one row per page:

```
{ "type": "page", "url": "https://example.com/docs/intro", "finalUrl": "https://example.com/docs/intro",
  "title": "Introduction", "markdown": "# Introduction\n\n...", "chars": 4210, "ok": true,
  "status": 200, "warnings": [], "billed": true }
```

Failed pages — separate error rows, never billed:

```
{ "type": "error", "url": "https://example.com/old-page", "ok": false,
  "stage": "page", "status": 404, "error": "HTTP 404", "billed": false }
```

Key-value store:

- `OUTPUT` — run summary: pages succeeded/failed, units charged, discovery source, notices, errors.
- `llms.txt`, `llms-full.txt` — when outputMode is `pages_and_llmstxt`.

### Reliability

Every page is processed in isolation. A page that fails, times out or throws never stops the run.
The run always finishes with a structured `OUTPUT`, even on invalid input.

### Limits

- Static HTML only. Pages that render content with JavaScript show up as error rows
  ("No extractable text") or with a `thin_content` warning.
- Tables are flattened to plain text.
- Only URLs on the same host as the input (www-insensitive) are converted.
- Per-page Markdown is capped at 60,000 characters (`markdown_truncated_60k` warning).
- Private/internal hosts are refused.

### Also available

- llms.txt Generator and AI Crawler Access Audit — free web tools at tools.newkwlab.com.

# Actor input Schema

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

Parallel page fetches. Lower it for small or fragile sites.

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

Maximum pages to convert. Default 100, cap 500. Values above 500 are capped with a notice, never rejected.

## `outputMode` (type: `string`):

Aggregated llms.txt files are saved to the key-value store at no extra cost.

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

Skip pages disallowed for this crawler. Skipped pages appear as error rows and are not charged.

## `siteUrl` (type: `string`):

Website start URL, e.g. https://example.com. Pages are discovered from robots.txt Sitemap lines, /sitemap.xml or /sitemap_index.xml, falling back to links on this page. Provide either siteUrl or sitemapUrl.

## `sitemapUrl` (type: `string`):

Direct sitemap URL (XML, sitemap index, or .xml.gz). If both fields are set, sitemapUrl is used.

## Actor input object example

```json
{
  "concurrency": 5,
  "maxPages": 100,
  "outputMode": "pages",
  "respectRobots": true,
  "siteUrl": "https://crawlee.dev"
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

## `output` (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 = {
    "siteUrl": "https://crawlee.dev"
};

// Run the Actor and wait for it to finish
const run = await client.actor("bin_ai_tools/sitemap-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 = { "siteUrl": "https://crawlee.dev" }

# Run the Actor and wait for it to finish
run = client.actor("bin_ai_tools/sitemap-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 '{
  "siteUrl": "https://crawlee.dev"
}' |
apify call bin_ai_tools/sitemap-to-markdown --silent --output-dataset

```

## MCP server setup

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