# Doc2RAG AI - Documentation to LLM-Ready Markdown Converter (`automation_studio/doc-to-rag-markdown-converter`) Actor

Convert technical documentation websites (Stripe, Supabase, Next.js, Mintlify, Docusaurus) into clean, LLM-ready Markdown with preserved multi-language code blocks, tables, and RAG frontmatter. Exports JSON dataset, single llms-full.txt, and ZIP archive.

- **URL**: https://apify.com/automation\_studio/doc-to-rag-markdown-converter.md
- **Developed by:** [Automation Studio](https://apify.com/automation_studio) (community)
- **Categories:** Developer tools, AI
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 clean llm-ready markdown documents

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

## Doc2RAG AI - Documentation to LLM-Ready Markdown Converter

> **The ultimate technical documentation scraper for AI agents and RAG pipelines.** Automatically crawl, clean, and convert technical documentation websites (Stripe, Supabase, Next.js, Mintlify, Docusaurus, GitBook) into pristine, LLM-ready Markdown with preserved multi-language code snippets, tables, and RAG YAML frontmatter.

***

### 🎯 Why Doc2RAG AI?

General-purpose web scrapers dump navigation bars, sidebars, cookie popups, and search modals into your vector database, diluting context quality and inflating token costs.

**Doc2RAG AI is engineered specifically for developers building RAG pipelines, Claude Projects, and Cursor IDE context:**

- 🛠️ **Framework Auto-Detection**: Recognizes Mintlify, Docusaurus, GitBook, Nextra, VitePress, Readme.io, and MkDocs to isolate the technical content body with 100% precision.
- 💻 **Multi-Language Code Tab Preservation**: Unlike naive scrapers that drop inactive tabs, Doc2RAG parses tabbed code containers and formats every language (cURL, Python, Node.js, Go) into distinct labeled Markdown fences.
- 📊 **Clean Table Conversion**: Formats HTML tables into clean GitHub-flavored Markdown tables.
- 🏷️ **RAG Frontmatter**: Injects structured YAML frontmatter (`title`, `url`, `headings`, `word_count`, `estimated_tokens`, `crawled_at`) for vector embeddings and document chunkers.
- 📦 **Triple Output Delivery**:
  1. **Structured JSON Dataset**: Per-page records with clean Markdown and metadata.
  2. **`documentation.zip`**: Downloadable ZIP folder hierarchy mirroring documentation URL subpaths.
  3. **`llms-full.txt`**: Consolidated single document with master Table of Contents, ready to drop into Claude Projects, NotebookLM, or ChatGPT.

***

### ⚡ Supported Documentation Engines

| Framework | Detection Signature | Code Tabs Preserved |
|---|---|---|
| **Docusaurus** | `.theme-doc-markdown`, `article` | ✅ All Languages |
| **Mintlify** | `#content-area`, `.prose` | ✅ All Languages |
| **GitBook** | `[data-testid="page.content"]` | ✅ All Languages |
| **Nextra** | `article.nextra-content` | ✅ All Languages |
| **VitePress** | `div.vp-doc`, `main` | ✅ All Languages |
| **MkDocs** | `article.md-content__inner` | ✅ All Languages |
| **Sphinx / ReadTheDocs** | `div[itemprop="articleBody"]` | ✅ All Languages |
| **Custom / Bespoke Docs** | Trafilatura NLP Extractor Fallback | ✅ All Languages |

***

### 📥 Input Example

```json
{
  "start_urls": [
    "https://docs.stripe.com/api"
  ],
  "max_pages": 50,
  "max_depth": 4,
  "strict_path_scoping": true,
  "preserve_code_tabs": true,
  "include_tables": true,
  "generate_zip": true,
  "generate_llms_txt": true
}
```

***

### 📤 Output Sample (Markdown with YAML Frontmatter)

````markdown
---
title: "Create a PaymentIntent"
url: "https://docs.stripe.com/api/payment_intents/create"
description: "Creates a PaymentIntent object to initiate payment collection."
framework: "Docusaurus"
word_count: 1420
estimated_tokens: 1890
crawled_at: "2026-09-13T12:00:00Z"
headings:
  - "Arguments"
  - "Returns"
  - "Code Examples"
---

## Create a PaymentIntent

Creates a PaymentIntent object to initiate payment collection.

#### Code Examples

**Python Example:**
```python
import stripe
stripe.api_key = "sk_test_..."
stripe.PaymentIntent.create(
  amount=2000,
  currency="usd",
  automatic_payment_methods={"enabled": True},
)
````

**Node.js Example:**

```javascript
const stripe = require('stripe')('sk_test_...');
const paymentIntent = await stripe.paymentIntents.create({
  amount: 2000,
  currency: 'usd',
  automatic_payment_methods: { enabled: true },
});
```

````

---

### 🚀 Quickstart: RAG Ingestion Example (LangChain)

```python
from apify_client import ApifyClient
from langchain_community.document_loaders import ApifyDatasetLoader
from langchain_text_splitters import MarkdownHeaderTextSplitter

## 1. Run Doc2RAG AI
client = ApifyClient("YOUR_APIFY_TOKEN")
actor_call = client.actor("automation_studio/doc-to-rag-markdown-converter").call(
    run_input={"start_urls": ["https://docs.stripe.com/api"], "max_pages": 50}
)

## 2. Ingest structured Markdown into LangChain
loader = ApifyDatasetLoader(
    dataset_id=actor_call["defaultDatasetId"],
    dataset_mapping_function=lambda item: Document(
        page_content=item["markdown"],
        metadata={"url": item["url"], "title": item["title"], "tokens": item["estimated_tokens"]}
    )
)
docs = loader.load()
````

# Actor input Schema

## `start_urls` (type: `array`):

Base documentation URL(s) to scrape (e.g. https://docs.stripe.com/api, https://supabase.com/docs).

## `max_pages` (type: `integer`):

Maximum number of documentation pages to crawl and convert.

## `max_depth` (type: `integer`):

Maximum link recursion depth from start URL.

## `strict_path_scoping` (type: `boolean`):

When enabled, crawler only follows URLs starting with the base path prefix (e.g. /api or /docs), preventing crawl leaks to marketing or login pages.

## `preserve_code_tabs` (type: `boolean`):

Extracts and formats all multi-language code tabs (e.g. cURL, Python, Node.js, Go) into distinct labeled Markdown code fences.

## `include_tables` (type: `boolean`):

Converts HTML tables to clean GitHub-flavored Markdown tables.

## `generate_zip` (type: `boolean`):

Generates a downloadable ZIP archive containing organized .md files matching the doc route structure.

## `generate_llms_txt` (type: `boolean`):

Generates a consolidated single text document with Table of Contents, perfect for Claude Projects or ChatGPT.

## `custom_css_selector` (type: `string`):

Optional CSS selector to target the doc article body (e.g. article, main, #content). If omitted, framework auto-detection is used.

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

Number of concurrent page fetch workers.

## `proxyConfiguration` (type: `object`):

Apify Proxy configuration. Recommended for Cloudflare/anti-bot protected doc sites.

## Actor input object example

```json
{
  "start_urls": [
    "https://docs.stripe.com/api"
  ],
  "max_pages": 25,
  "max_depth": 4,
  "strict_path_scoping": true,
  "preserve_code_tabs": true,
  "include_tables": true,
  "generate_zip": true,
  "generate_llms_txt": true,
  "concurrency": 5,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

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

Dataset containing clean LLM-ready Markdown with YAML frontmatter

# 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 = {
    "start_urls": [
        "https://docs.stripe.com/api"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("automation_studio/doc-to-rag-markdown-converter").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 = { "start_urls": ["https://docs.stripe.com/api"] }

# Run the Actor and wait for it to finish
run = client.actor("automation_studio/doc-to-rag-markdown-converter").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 '{
  "start_urls": [
    "https://docs.stripe.com/api"
  ]
}' |
apify call automation_studio/doc-to-rag-markdown-converter --silent --output-dataset

```

## MCP server setup

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

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/zTipyI9VFs8Buy2Yd/builds/l2R5Y4CP7d9oinRWa/openapi.json
