# Website & Docs to Clean Markdown & RAG Chunker for AI (`vertika/ai-web-to-markdown-rag`) Actor

Convert any Website, Documentation, or Blog into clean LLM-ready Markdown and semantic RAG chunks with token counts, metadata, tables & code preservation for AI Agents, MCP, LangChain & n8n.

- **URL**: https://apify.com/vertika/ai-web-to-markdown-rag.md
- **Developed by:** [José misael Quintero López](https://apify.com/vertika) (community)
- **Categories:** AI, Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.20 / 1,000 converted page & 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/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 & Docs to Clean Markdown & RAG Chunker for AI

Turn any **website, documentation site, or blog** into **clean, LLM-ready Markdown** and **semantic RAG chunks** in one run. Each chunk keeps its heading context and token count, so it drops straight into your embedding pipeline, vector database, or AI agent.

Built for **AI agents, MCP servers, LangChain, LlamaIndex, CrewAI, n8n, Make, Pinecone, and Supabase pgvector** workflows.

***

### What does this Actor do?

Raw HTML is noisy: navigation bars, cookie banners, scripts, and styling eat up tokens and confuse language models. This Actor fetches each URL, strips the noise, and returns:

- **Clean Markdown** that preserves headings, lists, links, fenced code blocks, and HTML tables.
- **Semantic RAG chunks** split on Markdown structure, each tagged with its nearest heading (`headingContext`), character count, and estimated token count.
- **Page metadata**: title, description, author, published date, language, canonical URL, Open Graph image and site name, and JSON-LD types.
- **Links**: internal and external links found on each page.
- **Token savings report**: how many tokens you save by sending Markdown instead of raw HTML, stored as a run summary in the key-value store.
- **Optional subpage discovery**: automatically follow internal links on your start pages, limited per domain and optionally by path prefix such as `/docs` or `/blog`.

### Who is it for?

| Use case | What you get |
| --- | --- |
| **AI agents & MCP tools** | Compact, readable page content that fits context windows |
| **RAG pipelines** | Chunks with heading context and token counts, ready to embed |
| **Documentation search** | Entire docs sections converted and chunked for semantic search |
| **Knowledge bases & chatbots** | Blogs and help centers turned into clean, citable source text |
| **No-code automation** | Results in a dataset you can pull into n8n, Make, or Zapier |
| **Fine-tuning & evaluation datasets** | Consistent Markdown plus metadata for every page |

### Key features

- **HTML to Markdown API alternative**: run it from the Apify Console, the API, or a scheduled task.
- **Boilerplate removal**: scripts, styles, and navigation chrome are removed before conversion.
- **Table preservation**: HTML `<table>` elements become Markdown pipe tables (optional).
- **Code block preservation**: `<pre><code>` blocks become fenced code blocks with language tags (optional).
- **Configurable RAG chunking**: set chunk size (100–4,000 tokens) and overlap (0–500 tokens).
- **Subpage crawling**: discover internal pages automatically, capped per domain (1–50 pages).
- **Path prefix filter**: crawl only the sections you care about.
- **Concurrency and timeouts**: tune parallel requests (1–20) and per-request timeout (5–60 seconds).
- **Structured output**: dataset views for overview, RAG chunks, and metadata & links.

### Quick start

1. Open the Actor in the Apify Store and click **Try for free**.
2. Enter one or more URLs in **URLs to convert**. The default example converts the Apify platform docs and the Apify about page.
3. Optionally enable **Auto-discover & crawl internal subpages** and set **Max pages per domain**.
4. Adjust **RAG chunk size** and **RAG chunk overlap** to match your embedding model and context window.
5. Click **Start**. When the run finishes, open the **Dataset** tab for results or the **Key-value store** for the `SUMMARY` report.

### Input

| Field | Type | Default | Description |
| --- | --- | --- | --- |
| `urls` | array of strings | Apify docs and about page | **Required.** Pages to convert. |
| `crawlSubpages` | boolean | `false` | Discover and convert internal links found on the start pages. |
| `maxPagesPerDomain` | integer (1–50) | `3` | Maximum pages processed per domain when crawling subpages. |
| `pathPrefixFilter` | string | `""` | Only follow subpages whose path starts with this prefix, e.g. `/docs`. |
| `includeRagChunks` | boolean | `true` | Generate semantic RAG chunks with heading context and token counts. |
| `chunkSizeTokens` | integer (100–4000) | `500` | Target size of each RAG chunk in estimated tokens. |
| `chunkOverlapTokens` | integer (0–500) | `50` | Tokens shared between consecutive chunks. |
| `preserveTables` | boolean | `true` | Convert HTML tables to Markdown tables. |
| `preserveCodeBlocks` | boolean | `true` | Keep fenced code blocks with language tags. |
| `includeLinksSummary` | boolean | `true` | Include the list of internal and external links per page. |
| `concurrency` | integer (1–20) | `5` | Number of pages processed in parallel. |
| `requestTimeoutSecs` | integer (5–60) | `15` | Timeout for each page request, in seconds. |

#### Example input

```json
{
  "urls": [
    "https://docs.apify.com/platform/actors"
  ],
  "crawlSubpages": true,
  "maxPagesPerDomain": 20,
  "pathPrefixFilter": "/platform",
  "includeRagChunks": true,
  "chunkSizeTokens": 500,
  "chunkOverlapTokens": 50,
  "preserveTables": true,
  "preserveCodeBlocks": true,
  "includeLinksSummary": true,
  "concurrency": 5,
  "requestTimeoutSecs": 15
}
```

### Output

#### Dataset item

Each processed page produces one dataset item:

```json
{
  "url": "https://docs.example.com/start",
  "finalUrl": "https://docs.example.com/start",
  "domain": "docs.example.com",
  "status": "success",
  "httpStatus": 200,
  "metadata": {
    "title": "Getting Started",
    "description": "Intro to actors",
    "author": "Jane Doe",
    "publishedDate": "2025-01-02T10:00:00Z",
    "language": "en",
    "canonicalUrl": "https://docs.example.com/start",
    "ogImage": "https://docs.example.com/og.png",
    "siteName": "Example Docs",
    "jsonLdTypes": ["Article"]
  },
  "markdown": "# Getting Started\n\nWelcome to ...",
  "wordCount": 842,
  "charCount": 5310,
  "estimatedTokens": 1330,
  "rawHtmlTokensEstimate": 9120,
  "tokenSavingsPercent": 85.4,
  "chunksCount": 3,
  "ragChunks": [
    {
      "chunkIndex": 0,
      "headingContext": "Getting Started",
      "text": "Welcome to ...",
      "charCount": 498,
      "estimatedTokens": 125
    }
  ],
  "links": [
    { "text": "the guide", "url": "https://docs.example.com/docs/guide", "isInternal": true }
  ],
  "responseTimeMs": 412,
  "processedAt": "2026-11-17T12:00:00.000Z"
}
```

#### Run summary

The `SUMMARY` record in the default key-value store contains run totals, including the aggregate token savings compared with raw HTML. Open the **Run Summary & Token Savings Report** link from the Actor's output tab.

#### Dataset views

- **Overview**: URL, title, word count, estimated tokens, token savings, chunk count, and Markdown.
- **RAG Chunks**: URL, title, chunk count, estimated tokens, and the chunks themselves.
- **Metadata & Links**: URL, domain, title, description, author, published date, JSON-LD types, and links.

### Using the output in AI and RAG pipelines

#### Python: load chunks into a vector store

```python
from apify_client import ApifyClient

client = ApifyClient("<APIFY_TOKEN>")
run = client.actor("vertika/ai-web-to-markdown-rag").call(run_input={
    "urls": ["https://docs.apify.com/platform/actors"],
    "chunkSizeTokens": 500,
    "chunkOverlapTokens": 50,
})

items = client.dataset(run["defaultDatasetId"]).iterate_items()
documents = []
for item in items:
    if item["status"] != "success":
        continue
    for chunk in item["ragChunks"]:
        documents.append({
            "text": chunk["text"],
            "metadata": {
                "url": item["url"],
                "title": item["metadata"]["title"],
                "heading": chunk["headingContext"],
                "tokens": chunk["estimatedTokens"],
            },
        })

## Embed `documents` and upsert into Pinecone, Supabase pgvector, Qdrant, Chroma, etc.
```

#### JavaScript: LangChain-style documents

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

const client = new ApifyClient({ token: '<APIFY_TOKEN>' });
const run = await client.actor('vertika/ai-web-to-markdown-rag').call({
    urls: ['https://docs.apify.com/platform/actors'],
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();

const docs = items
    .filter((item) => item.status === 'success')
    .flatMap((item) =>
        item.ragChunks.map((chunk) => ({
            pageContent: chunk.text,
            metadata: {
                source: item.url,
                title: item.metadata.title,
                heading: chunk.headingContext,
                estimatedTokens: chunk.estimatedTokens,
            },
        })),
    );

// Pass `docs` to a LangChain vector store, a LlamaIndex index, or a CrewAI knowledge source.
```

#### No-code: n8n, Make, and Zapier

1. Add the **Apify** node (n8n) or the **Apify** module (Make) and choose *Run Actor*.
2. Select `vertika/ai-web-to-markdown-rag` and pass your input JSON.
3. Add a *Get dataset items* step, then split `ragChunks` into one item per chunk.
4. Send each chunk to an embeddings node and your vector store (Pinecone, Supabase pgvector, or any other).

#### MCP server and AI agents

Use the Actor as a web-reading tool for an MCP server or agent: call it with one or a few URLs, then give the agent the `markdown` field, or the most relevant `ragChunks`, instead of raw HTML. This keeps prompts small and answers grounded in the source page.

### Tips for better RAG results

- **Match chunk size to your model.** 300–800 tokens works well for most embedding models. Use larger chunks when you need more surrounding context per answer.
- **Use overlap for continuity.** A 10% overlap (for example, 50 tokens for 500-token chunks) helps keep definitions and steps that span chunk boundaries.
- **Crawl only what you need.** Combine `crawlSubpages` with `pathPrefixFilter` and `maxPagesPerDomain` to index a documentation section without pulling in the whole site.
- **Filter on metadata.** Store `url`, `title`, and `headingContext` with each vector so you can cite sources and filter by section.
- **Re-run on a schedule.** Use an Apify schedule to keep your knowledge base in sync with documentation updates.

### Frequently asked questions

**Does it work on JavaScript-heavy sites?**
The Actor is optimized for server-rendered documentation, blogs, and content pages. Pages that render all content with client-side JavaScript may return less text.

**What is a RAG chunk?**
A RAG chunk is a section of a page sized to fit into an embedding model and an LLM context window. Each chunk is tagged with the heading it belongs to, so retrieval results stay meaningful.

**How are tokens estimated?**
Token counts are estimates based on text length, intended for budgeting and chunk sizing. They are not tied to a specific tokenizer, so expect small differences from your model's exact count.

**Can I use it as an HTML to Markdown API?**
Yes. Call the Actor through the Apify API with `urls` set to the pages you want and read the results from the dataset. The Markdown is in the `markdown` field of each item.

**Does it respect robots.txt or rate limits?**
Use `concurrency` and `requestTimeoutSecs` to keep request rates reasonable. Always make sure your use complies with the target site's terms and applicable law.

### Check Out Our Other Popular Tools

Looking for more ways to grow your business with AI?

- **[B2B Website Lead Enricher, Tech Stack & SEO/AI Auditor](https://apify.com/vertika/b2b-lead-ai-auditor)**: enrich B2B leads, detect website tech stacks, and audit SEO and AI readiness in one run.

### Need a custom AI or RAG automation?

Need something tailored to your stack, such as a custom crawler, a RAG pipeline into your own vector database, an MCP server for your product docs, or an n8n/Make workflow for your team? Open an issue in the **[Issues tab](../../issues)** of this Actor describing your use case, and we will get back to you about a custom solution.

### Free tool: GEO Score

Curious how AI-ready your own site is? Try **[GEO Score](https://api.apify.com/v2/key-value-stores/2vJIgTfdD08OH8WNb/records/index.html?signature=r6qQ5TQOFpxrWmUAZLzb)**, a free 2-minute checker that scores any domain for AI-search readiness: GPTBot / ClaudeBot / PerplexityBot access, `llms.txt`, `Schema.org`, and technical basics. You get a 0–100 score, your three biggest gaps, and copy-paste fixes. No signup, and nothing is uploaded to a server.

Want the full audit done for you? Copy your report, open an issue in the **Issues** tab of the [B2B Auditor Actor](https://apify.com/vertika/b2b-lead-ai-auditor) with the title `Free GEO Audit Request`, and paste up to 5 domains. We will send back a free manual GEO audit.

### Support

Found a bug or have a feature request? Open an issue in the **Issues** tab of this Actor. Please include the input you used (with any private URLs removed) and the run ID when possible.

### Keywords

Website to Markdown for AI Agents · RAG Chunker · Documentation Scraper for LLMs · HTML to Clean Markdown API · MCP Server Tool · LangChain loader · LlamaIndex loader · CrewAI knowledge source · n8n RAG workflow · Make RAG workflow · Pinecone loader · Supabase pgvector loader · Markdown for LLM context · web scraper for embeddings

# Actor input Schema

## `urls` (type: `array`):

List of website, documentation or blog page URLs to convert into clean Markdown and RAG chunks.

## `crawlSubpages` (type: `boolean`):

When enabled, internal links found on the start pages are discovered and converted too.

## `maxPagesPerDomain` (type: `integer`):

Maximum number of pages to process for each domain when subpage crawling is enabled.

## `pathPrefixFilter` (type: `string`):

Only crawl subpages whose URL path starts with this prefix. Leave empty to allow all paths.

## `includeRagChunks` (type: `boolean`):

Split each page into overlapping chunks that keep their heading context, ready for embedding and vector databases.

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

Approximate target size of each RAG chunk in estimated tokens.

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

Number of tokens shared between consecutive RAG chunks to preserve context across boundaries.

## `preserveTables` (type: `boolean`):

Convert HTML <table> elements into Markdown pipe tables so structured data stays readable for LLMs.

## `preserveCodeBlocks` (type: `boolean`):

Keep <pre><code> blocks as fenced Markdown code blocks, including the language tag when available.

## `includeLinksSummary` (type: `boolean`):

Add a list of internal and external links found on each page to the output.

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

Number of pages processed in parallel.

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

Maximum time to wait for a single page response before it is marked as failed.

## Actor input object example

```json
{
  "urls": [
    "https://docs.apify.com/platform/actors",
    "https://apify.com/about"
  ],
  "crawlSubpages": false,
  "maxPagesPerDomain": 3,
  "pathPrefixFilter": "",
  "includeRagChunks": true,
  "chunkSizeTokens": 500,
  "chunkOverlapTokens": 50,
  "preserveTables": true,
  "preserveCodeBlocks": true,
  "includeLinksSummary": true,
  "concurrency": 5,
  "requestTimeoutSecs": 15
}
```

# Actor output Schema

## `results` (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 = {
    "urls": [
        "https://docs.apify.com/platform/actors",
        "https://apify.com/about"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("vertika/ai-web-to-markdown-rag").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 = { "urls": [
        "https://docs.apify.com/platform/actors",
        "https://apify.com/about",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("vertika/ai-web-to-markdown-rag").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 '{
  "urls": [
    "https://docs.apify.com/platform/actors",
    "https://apify.com/about"
  ]
}' |
apify call vertika/ai-web-to-markdown-rag --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,vertika/ai-web-to-markdown-rag"
        }
    }
}
```

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/vaCHnC6AaNpruW4HA/builds/IQUfRHExkmWlUFTmb/openapi.json
