# Website to Markdown for LLM & RAG: Crawl, Clean, Chunk (`larkmoor/website-to-markdown`) Actor

Crawl any website or docs and convert every page to clean, LLM-ready Markdown: boilerplate removed, links absolute, tables kept, token counts, heading-aware RAG chunks with overlap, plus llms.txt and llms-full.txt for the whole site. No browser, fast. $1 per 1,000 pages.

- **URL**: https://apify.com/larkmoor/website-to-markdown.md
- **Developed by:** [Larkmoor Data](https://apify.com/larkmoor) (community)
- **Categories:** AI, 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 $0.85 / 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: Crawl, Clean, Chunk

Turn any website, blog or documentation into **clean, LLM-ready Markdown**. Give it a start URL; it crawls the site, removes the boilerplate (menus, cookie banners, footers, ads, scripts), keeps headings, lists, code blocks, tables and absolute links, and returns one tidy Markdown document per page with its title, description, language, word count and **token estimate**.

For retrieval-augmented generation it also cuts every page into **heading-aware chunks** with overlap, each carrying its heading path ("Quickstart > Response Content"), ready for your embedding model and vector database. At the end of the run you get an **llms.txt** index and an **llms-full.txt** file with the whole site in one Markdown document.

Plain HTTP, no browser: fast, and cheap at **$1 per 1,000 pages**.

### What does Website to Markdown do?

- **Crawls** from your start URLs over same-site links, up to the depth and page count you set; can stay inside a folder (/docs/) or cover the whole domain, and can add every page from the site's **sitemap**.
- **Include / exclude patterns**: globs (`https://example.com/blog/**`) or regular expressions (`re:/v2/`).
- **Cleans** each page: main-content extraction removes navigation and clutter; "full page" mode keeps the whole body except menus, header and footer.
- Converts to **Markdown**: ATX headings, lists, fenced code, tables, links made absolute, Sphinx/Docs "¶" anchors removed.
- Adds `title`, `description`, `language`, `canonicalUrl`, `headings`, `wordCount`, `tokenEstimate` and a `contentHash` for change detection.
- **RAG chunks**: target size and overlap in tokens, split on headings first, then paragraphs; giant paragraphs are split at sentence ends.
- Skips duplicate pages (same content under another URL), tracking parameters, login/cart pages and files.
- Saves **llms.txt** and **llms-full.txt** in the run's key-value store.
- Respects robots.txt. Failed, empty, blocked and duplicate pages are **never charged**. Honors the run's Max items option and your spend limit.

### Who is it for?

- **AI engineers** feeding docs, help centers and websites into RAG pipelines, vector databases and custom GPTs.
- **Developers** building chatbots and support assistants on a product's documentation.
- **Content and SEO teams** exporting a site's text for audits, migrations or LLM rewriting.
- **Researchers** building text corpora from public websites.
- **Site owners** generating an llms.txt for their own site.

### Input

| Field | What it does |
|---|---|
| `startUrls` | pages or sites to start from |
| `maxPages` | most pages converted (default 50) |
| `maxDepth` | link depth from the start URLs (0 = start URLs only) |
| `stayUnderStartPath` | stay inside the start folder (default on) |
| `useSitemap` | also queue the site's sitemap pages |
| `includeUrlPatterns` / `excludeUrlPatterns` | globs or `re:` regular expressions |
| `contentMode` | `main` (boilerplate removed) or `full` |
| `outputMode` | `pages`, `pagesWithChunks` or `chunks` (one row per chunk) |
| `chunkSizeTokens` / `chunkOverlapTokens` | chunk sizing (default 500 / 50) |
| `keepLinks` / `keepImages` / `keepTables` | what to keep in the Markdown |
| `saveLlmsTxt` | save llms.txt and llms-full.txt (default on) |

```json
{
  "startUrls": ["https://docs.python-requests.org/en/latest/"],
  "maxPages": 200,
  "maxDepth": 3,
  "outputMode": "chunks",
  "chunkSizeTokens": 500,
  "chunkOverlapTokens": 50
}
```

### Output

One row per page (`pages`):

```json
{
  "url": "https://docs.python-requests.org/en/latest/user/quickstart/",
  "title": "Quickstart — Requests 2.34.2 documentation",
  "description": null,
  "language": "en",
  "markdown": "# Quickstart\n\nEager to get started? ...\n\n## Make a Request\n...",
  "wordCount": 2799,
  "tokenEstimate": 4610,
  "headings": ["Quickstart", "Make a Request", "Passing Parameters In URLs", "..."],
  "canonicalUrl": "https://docs.python-requests.org/en/latest/user/quickstart/",
  "contentHash": "3f1c0d9a27b84e11",
  "crawledAt": "2026-11-03T11:45:02Z"
}
```

One row per chunk (`chunks`):

```json
{
  "url": "https://docs.python-requests.org/en/latest/user/quickstart/",
  "title": "Quickstart — Requests 2.34.2 documentation",
  "chunkIndex": 3,
  "chunkCount": 23,
  "headingPath": "Quickstart > Response Content",
  "text": "## Response Content\n\nWe can read the content of the server's response...",
  "tokens": 168
}
```

Pages that fail come back with an `error` (blocked, robots.txt, not HTML, needs JavaScript) and are free. Export as JSON, JSONL, CSV or Excel, or read through the Apify API; `llms.txt` and `llms-full.txt` are in the run's key-value store (linked from the run's Output tab).

### How much does it cost?

- **$1.00 per 1,000 pages converted** (all chunks of a page are included)
- Failed, empty, blocked and duplicate pages: **free**
- $0.001 per run start

Worked examples:

1. **A product's documentation, 300 pages, chunked for a support bot:** 300 × $0.001 = **$0.30**.
2. **A company blog of 2,000 posts from its sitemap:** **about $2.00**.
3. **Weekly refresh of 20 help-center sites, 500 pages each (10,000 pages):** **about $10** a week. Use `contentHash` to re-embed only changed pages.

Bronze, Silver and Gold Apify plans pay less per page. Compute is small (256 MB, plain HTTP).

### Tips

- **Docs only:** start at the docs folder (`/docs/`) and keep `stayUnderStartPath` on.
- **Whole site fast:** turn on `useSitemap` with `maxDepth` 0.
- **Skip noise:** exclude `**/tag/**`, `**/page/**`, `re:\?replytocom=`.
- **Chunk size:** 300–800 tokens suits most embedding models; overlap of 10% keeps sentences intact across boundaries.
- **JavaScript-only sites** (pages that are empty without a browser) are reported as "almost no text"; most docs, blogs and marketing sites render on the server and work.

### FAQ

**How is this different from a generic web scraper?**
It is built for one job: clean text for language models. No selectors to write, no browser to pay for, chunking and llms.txt included.

**Is it legal?**
It reads publicly available pages you choose and follows robots.txt. It does not log in. Respect each site's copyright and terms for what you do with the text; keep the `url` with every chunk so answers can cite the source. Sites whose terms forbid automated access (for example Google, LinkedIn, Facebook, Instagram, Amazon) are not crawled.

**How accurate is the token estimate?**
About 4 characters per token, close to common tokenizers for English. Use your own tokenizer when you need exact counts.

**Does it deduplicate?**
Yes. Pages with identical content (http/https, www, tracking parameters, print versions) are converted once; duplicates are left out and not charged.

### Integrations

Send chunks to Pinecone, Qdrant, Weaviate, Milvus or Supabase with Apify integrations or your own code, load them in LangChain or LlamaIndex with the Apify dataset loader, run it from Make, Zapier or n8n, or let an AI agent call it through the Apify MCP server.

### Changelog

- **0.1** (Nov 2026): first release. Same-site crawl with depth, folder scope, sitemap, include/exclude patterns; main-content and full-page Markdown; absolute links, tables, code; titles, language, canonical, token estimate, content hash; heading-aware chunks with overlap; llms.txt and llms-full.txt; robots.txt; duplicate skipping.

# Actor input Schema

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

Pages or sites to convert. The crawler starts here and follows links on the same site (see Max crawl depth).

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

Most pages converted (and charged) in this run.

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

How many links away from a start URL to go. 0 = only the start URLs (and sitemap URLs if on).

## `stayUnderStartPath` (type: `boolean`):

Only follow links that start with the start URL's folder (e.g. /docs/ stays in the docs). Turn off to crawl the whole domain.

## `useSitemap` (type: `boolean`):

Read the site's sitemap (from robots.txt or /sitemap.xml) and queue its pages too: the fastest way to cover a whole site.

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

Optional globs like https://example.com/blog/\*\* or regular expressions prefixed with re: (e.g. re:/docs/v2/). A URL must match one of them to be crawled.

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

Globs or re: regular expressions for URLs to skip (e.g. **/tag/**, re:?page=).

## `contentMode` (type: `string`):

Main content keeps the article/docs text and drops navigation, ads, cookie banners and related links. Full page keeps everything inside the page body except menus, header, footer and scripts.

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

Chunks are heading-aware pieces of the Markdown, sized for embeddings, each with its heading path. Either way you pay per page.

## `chunkSizeTokens` (type: `integer`):

Target chunk size in tokens (about 4 characters per token).

## `chunkOverlapTokens` (type: `integer`):

Text repeated from the end of the previous chunk, so a sentence cut at a boundary keeps its context.

## `keepLinks` (type: `boolean`):

Keep hyperlinks as Markdown links (absolute URLs).

## `keepImages` (type: `boolean`):

Keep images as Markdown image links.

## `keepTables` (type: `boolean`):

Keep HTML tables as Markdown tables.

## `saveLlmsTxt` (type: `boolean`):

Also save an llms.txt index (title, link, description per page) and llms-full.txt (all pages in one Markdown file) in the run's key-value store.

## `minTextChars` (type: `integer`):

Pages with less text than this are reported as empty (free), e.g. pages that need JavaScript.

## `skipFailed` (type: `boolean`):

Leave blocked, empty and non-HTML pages out of the dataset (they are never charged either way).

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

Skip pages the site's robots.txt disallows (recommended).

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

Pages fetched at the same time (1-10).

## Actor input object example

```json
{
  "startUrls": [
    "https://docs.python-requests.org/en/latest/"
  ],
  "maxPages": 50,
  "maxDepth": 2,
  "stayUnderStartPath": true,
  "useSitemap": false,
  "contentMode": "main",
  "outputMode": "pages",
  "chunkSizeTokens": 500,
  "chunkOverlapTokens": 50,
  "keepLinks": true,
  "keepImages": false,
  "keepTables": true,
  "saveLlmsTxt": true,
  "minTextChars": 100,
  "skipFailed": false,
  "respectRobotsTxt": true,
  "concurrency": 5
}
```

# Actor output Schema

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

All pages (or chunks) as JSON items in the run's default dataset (also downloadable as CSV/Excel).

## `llmsTxt` (type: `string`):

Index of the converted pages (title, link, description).

## `llmsFullTxt` (type: `string`):

All converted pages in one Markdown file.

# 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.python-requests.org/en/latest/"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("larkmoor/website-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 = { "startUrls": ["https://docs.python-requests.org/en/latest/"] }

# Run the Actor and wait for it to finish
run = client.actor("larkmoor/website-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 '{
  "startUrls": [
    "https://docs.python-requests.org/en/latest/"
  ]
}' |
apify call larkmoor/website-to-markdown --silent --output-dataset

```

## MCP server setup

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