# Website to Markdown & Sitemap Scraper (`skusol/website-to-markdown-scraper`) Actor

Turn websites and XML sitemaps into clean Markdown for AI, RAG and research. Crawl internal links, keep tables and code, export text and optional chunks. Pay only for extracted pages. No API key required.

- **URL**: https://apify.com/skusol/website-to-markdown-scraper.md
- **Developed by:** [Kusol Sukhakul](https://apify.com/skusol) (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

$1.50 / 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.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — 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 Markdown & Sitemap Scraper

**Paste a website URL. Get clean Markdown for AI, RAG, search and research.**

Extract public website content without writing a crawler. Discover pages from internal links, `robots.txt` and XML sitemaps, remove common navigation clutter, and export readable Markdown with headings, tables, code blocks and absolute links.

**$1.50 per 1,000 successfully extracted pages. No startup fee. Platform usage included.** Errors, duplicate final URLs and sitemap discovery do not trigger extraction charges. No LLM API key or separate proxy subscription is required.

### Get started

1. Paste a public HTTPS website, page, or XML sitemap URL.
2. Set **Maximum extracted pages**. Start with 5–10 to check the output.
3. Run the Actor. Open **Markdown content** in the Dataset or download **Combined Markdown** from Output.

Example: collect a small documentation section.

```json
{
  "startUrls": [{"url": "https://docs.apify.com/actors/development/actor-definition/actor-json"}],
  "maxPages": 5,
  "includeUrlPrefixes": ["https://docs.apify.com/actors/development/actor-definition/"],
  "useSitemaps": true,
  "crawlLinks": true,
  "includeChunks": true
}
```

For a whole website, remove `includeUrlPrefixes`. To fetch only your supplied pages, set `useSitemaps: false` and `maxDepth: 0`.

### What you get

- Clean `markdown` and readable `text` for each successful page.
- Page title, meta description, HTML language, headings and content links.
- Requested URL, final URL, declared canonical URL and collection time.
- SHA-256 document and content IDs for downstream deduplication.
- Optional deterministic Markdown chunks for RAG pipelines.
- A combined Markdown file and a run summary explaining when crawling stopped.

The declared canonical URL is metadata only: the Actor does not trust it as a redirect or use it to discard other pages. Identical content on different URLs remains separate. Redirect aliases resolving to an already delivered URL are skipped within the run.

### Example output

Illustrative successful Dataset item (shortened):

```json
{
  "status": "SUCCESS",
  "url": "https://example.com/docs/start",
  "finalUrl": "https://example.com/docs/start",
  "title": "Getting started",
  "description": "Set up your first project.",
  "language": "en",
  "markdown": "# Getting started\n\nCreate your first project...",
  "text": "Getting started\nCreate your first project...",
  "headings": [{"level": 1, "text": "Getting started"}],
  "links": ["https://example.com/docs/install"],
  "depth": 1,
  "discoveredFrom": "link",
  "httpStatus": 200
}
```

Actual results also include `documentId`, `contentHash`, `characterCount`, `wordCount`, `canonicalUrl`, `scrapedAt`, and optional `chunks`. Word count uses whitespace segmentation; it is not a linguistic word count for Thai, Chinese, or similar languages.

An unavailable page produces an **uncharged** `ERROR` row with its URL and reason. Filter `status == "SUCCESS"` before sending rows to your AI or database.

### Pricing and spending limits

| Successful pages | Extraction charge |
|---:|---:|
| 1 | $0.0015 |
| 10 | $0.015 |
| 100 | $0.15 |
| 1,000 | $1.50 |

One `page-extracted` event is charged after a successful result is saved to the Dataset. There is no startup charge, and Apify platform usage is included in this Actor's event price. Use the run's maximum total charge alongside `maxPages` to control spending. A run stops when the budget cannot cover another page.

Each run is a fresh crawl, so pages successfully extracted again on another run are charged again. Free-plan credits may be used according to Apify's current account rules. Separate downstream tools can have their own costs.

### Crawl controls

| Input | Default | Purpose |
|---|---|---|
| `startUrls` | Required | 1–20 public HTTPS pages, websites or XML sitemap URLs. API also accepts bare domains. |
| `maxPages` | 10 | Maximum successful pages per run, from 1 to 1,000. |
| `useSitemaps` | true | Read sitemap declarations and `/sitemap.xml`, including indexes and gzip. |
| `crawlLinks` | true | Follow internal links. |
| `maxDepth` | 3 | Maximum link depth. Start URLs and sitemap entries start at depth 0. |
| `includeUrlPrefixes` | Empty | Export only matching full URL prefixes. |
| `excludeUrlPrefixes` | Empty | Exclude matching discovered URLs. |
| `sitemapUrls` | Empty | Additional sitemap URLs on the supplied websites. |
| `contentSelector` | Automatic | Select the article or content container. |
| `removeSelectors` | Empty | Remove additional CSS-selected sections. |
| `includeChunks` | false | Include Markdown chunks with deterministic IDs. |
| `chunkSize` | 2,000 | Maximum characters per chunk, from 500 to 8,000. |

Only supplied hostnames and their `www` aliases are crawled. Other subdomains must be added explicitly. URL prefix matching is literal and case-sensitive; use a trailing slash to target a section. Supplied start pages can be read for discovery even if outside the export prefixes. Navigation links are used for discovery before navigation is removed from the content.

Tracking parameters and fragments are removed from crawl URLs; functional query parameters are retained. HTTP-only pages, authenticated pages, private networks and nonstandard ports are not supported.

### Use with n8n, Make or an API

**n8n:** use the Apify node to run `skusol/website-to-markdown-scraper`, wait for completion, then retrieve Dataset items. Filter on `status` and map `markdown`, `url`, and `title` to your next node. You can also use HTTP Request nodes with the official Apify REST API.

**Make:** connect your Apify account, add **Run an Actor**, select this Actor and supply the input JSON. Wait for the run to finish, then use **Get Dataset Items** with its default Dataset ID. A scheduled scenario can refresh your content periodically.

**JavaScript** using the official `apify-client` package:

```javascript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('skusol/website-to-markdown-scraper').call({
  startUrls: [{ url: 'https://docs.apify.com/actors/development/actor-definition/actor-json' }],
  maxPages: 5,
  includeUrlPrefixes: ['https://docs.apify.com/actors/development/actor-definition/'],
  includeChunks: true
}, { maxTotalChargeUsd: 0.015 });
const { items } = await client.dataset(run.defaultDatasetId).listItems();
const pages = items.filter(item => item.status === 'SUCCESS');
```

For large result sets, paginate Dataset reads. These examples describe integration steps; no n8n or Make scenario, vector database, embeddings or LLM processing is automatically created by the Actor.

### Limits and troubleshooting

- **Public HTML, plain text and Markdown only.** JavaScript is not rendered. PDFs, Office documents, images, videos, login sessions and anti-bot bypass are outside this version's scope.
- `robots.txt` is respected. An unavailable or invalid robots file causes a skip, except HTTP 404/410 which means no robots rules were found.
- Sitemap discovery is bounded to 20 XML requests, five index levels, 100 queued sitemap files and 10,000 page URLs. A sitemap can be much larger than the selected page limit; completeness is not guaranteed.
- Limits: 2 MB per page response, 5 MB per sitemap after decompression, 150,000 Markdown characters per page. UTF-8 content is expected.
- Page attempts are capped at `3 × maxPages + 10`. The crawler stops after roughly 14 minutes plus any in-flight request. `SUMMARY.stopReason` identifies page, budget, attempt or time limits.
- Combined Markdown is capped at 20 MB. `SUMMARY.bundleOmittedPages` reports pages omitted from the bundle; their delivered content remains in the Dataset. The bundle is finalized when the run finishes normally; Dataset rows are available progressively.
- Empty pages, bot challenge pages and selectors matching no content produce explicit errors. If all page extractions fail, the run fails without extraction event charges.
- Each run starts over; there is no cross-run cache, automatic change comparison or resumable crawl state. For scheduled content changes, see [Website Change Monitor & RAG Knowledge Sync](https://apify.com/skusol/website-knowledge-monitor).

Use the Actor for content you are permitted to collect. Website content is untrusted data; review it before applying it as instructions in an AI workflow.

### Support

Open an issue on this Actor with the run ID, a public example URL, expected output and the relevant error or summary. Do not include passwords, cookies or API tokens.

# Actor input Schema

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

1–20 public HTTPS websites, pages or XML sitemap URLs. Bare domains are accepted through the API. Crawls only the supplied hostnames and www aliases.

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

Maximum successful page results across all websites. Errors and sitemap files do not count. Also set the Apify run spending limit to cap charges.

## `useSitemaps` (type: `boolean`):

Reads robots.txt sitemap declarations and /sitemap.xml. Supports XML sitemap indexes and gzip. Up to 20 sitemap requests and 10,000 queued URLs.

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

Discovers links on the supplied websites. External websites are never added.

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

Start pages and sitemap entries have depth 0. Set 0 and turn off sitemap discovery to fetch only supplied pages.

## `includeUrlPrefixes` (type: `array`):

Only export URLs starting with one of these full HTTPS prefixes. For example https://example.com/docs/. Empty includes the entire supplied hostname. Start pages may still be read for discovery.

## `excludeUrlPrefixes` (type: `array`):

Skip matching discovered URLs, for example https://example.com/account/. Exclusion wins over inclusion.

## `sitemapUrls` (type: `array`):

Extra XML sitemap URLs on supplied websites. Used when sitemap discovery is enabled.

## `contentSelector` (type: `string`):

Leave empty to detect main, role=main, article or body. For precise extraction use a selector such as .article-body. Unmatched selectors produce an uncharged error.

## `removeSelectors` (type: `string`):

Additional CSS selectors to remove, such as .sidebar, .advertisement. Common navigation, scripts, forms and cookie banners are removed automatically.

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

Adds deterministic chunk IDs and Markdown text segments to each result. No embeddings or LLM calls are made.

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

Used only when chunks are enabled. Prefers newline boundaries; this is a character count, not a token limit.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://docs.apify.com/actors/development/actor-definition/actor-json"
    }
  ],
  "maxPages": 5,
  "useSitemaps": true,
  "crawlLinks": true,
  "maxDepth": 3,
  "includeUrlPrefixes": [
    "https://docs.apify.com/actors/development/actor-definition/"
  ],
  "excludeUrlPrefixes": [],
  "sitemapUrls": [],
  "contentSelector": "",
  "removeSelectors": "",
  "includeChunks": false,
  "chunkSize": 2000
}
```

# Actor output Schema

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

No description

## `markdown` (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": [
        {
            "url": "https://docs.apify.com/actors/development/actor-definition/actor-json"
        }
    ],
    "maxPages": 5,
    "includeUrlPrefixes": [
        "https://docs.apify.com/actors/development/actor-definition/"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("skusol/website-to-markdown-scraper").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/actors/development/actor-definition/actor-json" }],
    "maxPages": 5,
    "includeUrlPrefixes": ["https://docs.apify.com/actors/development/actor-definition/"],
}

# Run the Actor and wait for it to finish
run = client.actor("skusol/website-to-markdown-scraper").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": [
    {
      "url": "https://docs.apify.com/actors/development/actor-definition/actor-json"
    }
  ],
  "maxPages": 5,
  "includeUrlPrefixes": [
    "https://docs.apify.com/actors/development/actor-definition/"
  ]
}' |
apify call skusol/website-to-markdown-scraper --silent --output-dataset

```

## MCP server setup

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

```

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/5C58gg6wvBZw5tngO/builds/09vhz0DR9Al7vPhhz/openapi.json
