# Document to Markdown | PDF, Word, Excel, OCR for RAG & LLM (`trev0n/document-to-markdown`) Actor

Convert PDF, Word, PowerPoint, Excel, CSV, HTML, EPUB and images from URLs to clean Markdown or text: headings, lists and tables kept, OCR for scans, RAG-ready chunks.

- **URL**: https://apify.com/trev0n/document-to-markdown.md
- **Developed by:** [Paweł](https://apify.com/trev0n) (community)
- **Categories:** AI, Developer tools, Integrations
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 document converteds

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

## 📄 Document to Markdown | PDF, Word, Excel, OCR for RAG & LLM

🎯 **Turn any document link into clean, structured Markdown that ChatGPT, Claude and your RAG pipeline can actually use.**

Paste links to **PDF, Word, PowerPoint, Excel, CSV, HTML, EPUB or image files** and get back clean Markdown with **real headings, bullet lists, tables and links**, plus plain text, page counts, titles and authors. Scanned pages and photos are read with **OCR in 25 languages**, and long documents can be split into **RAG-ready chunks** that remember which section they came from.

### 🚀 What Does It Do?

This tool downloads every document you list and converts it into **structured, ready-to-use text**. It rebuilds the document's outline instead of dumping raw characters: titles become `#` headings, numbered sections like `3.1 Encoder` become sub-headings, bullet points become lists, Word and Excel tables become Markdown tables, and running headers, footers and page numbers are removed. No manual copy-pasting, no broken line wraps.

💡 **Two ways to get your results:**

1. **📋 One row per document**: the full Markdown and/or text of each file, with title, author, dates, page and word counts.
2. **🧩 One row per chunk**: documents split into token-sized pieces with their section path, ready to embed and load into Pinecone, Weaviate, Qdrant, pgvector or any vector database.

### 👥 Who Is This For?

| 🏢 Use Case                     | 💬 How It Helps                                                                          |
| ------------------------------- | ---------------------------------------------------------------------------------------- |
| 🤖 **AI & RAG developers**      | Feed clean, chunked Markdown into embeddings and chatbots instead of garbled PDF text    |
| ⚖️ **Legal & compliance teams** | Convert contracts, policies and filings into searchable text with their structure intact |
| 🔬 **Researchers & analysts**   | Extract papers and reports into Markdown for notes, summaries and literature reviews     |
| 🧾 **Back-office automation**   | OCR scanned invoices, forms and receipts into text for downstream parsing                |
| 📚 **Knowledge-base builders**  | Migrate Word, PowerPoint and Excel files into wikis, Notion or static sites              |
| 🛠️ **No-code builders**         | Plug document text into Make, Zapier or n8n flows with one API call                      |

### ✨ Features

- 📄 **9 formats**: PDF, Word (.docx), PowerPoint (.pptx), Excel (.xlsx, .xls), CSV, HTML pages, EPUB e-books, images and plain text
- 🏗️ **Real document structure**: headings detected from font sizes and section numbers, lists, bold and italic, links
- 📊 **Tables kept as tables**: Word, Excel, PowerPoint and HTML tables come out as clean Markdown tables
- 🧹 **Noise removed**: running headers, footers, page numbers, margin watermarks, menus and cookie banners
- 🔍 **OCR for scans and photos**: 25 languages, automatic for pages without a text layer, or forced for every page
- 🧩 **RAG chunks**: configurable size and overlap, split on headings and paragraphs, with the section path on every chunk
- 🗒️ **Speaker notes**: PowerPoint notes included under each slide
- 🔐 **Password-protected PDFs**: unlock with your password
- 🏷️ **Metadata**: title, author, created and modified dates, page count, word count, file size
- ⚡ **Fast & Scalable**: a 15-page research paper converts in about a second; files are processed in parallel
- 🛡️ **Graceful errors**: a broken link or unsupported file becomes an error row, the rest of the batch continues
- 📤 **Export Anywhere**: Download results as JSON, CSV, Excel, or push to Google Sheets, Zapier, Make, or your CRM

### 🎛️ Filters & Options

| Option                           | What It Does                                |
| -------------------------------- | ------------------------------------------- |
| 🔗 **Document URLs**             | Links to the files you want converted       |
| 📝 **Output format**             | Markdown, plain text, or both               |
| 🧩 **One row per**               | Whole document or chunk                     |
| 📏 **Chunk size & overlap**      | Chunk length and repeated context in tokens |
| 🔍 **OCR**                       | Auto, always or off                         |
| 🌍 **OCR languages**             | The languages printed in your scans         |
| 📑 **Max pages per document**    | Stop after the first N pages of a PDF       |
| 📊 **Max rows per sheet**        | Limit very large spreadsheets               |
| 📃 **Include per-page Markdown** | Adds the Markdown of every page separately  |
| 🗒️ **Include speaker notes**     | PowerPoint presenter notes on or off        |
| 🔐 **PDF password**              | Opens protected PDFs                        |
| 📦 **Max file size**             | Skips files above the limit                 |
| ⚙️ **Files in parallel**         | How many documents are converted at once    |
| 🌐 **Proxy**                     | Only for file hosts that block downloads    |

### 📦 What You Get (Output Fields)

Every document includes:

#### 📄 Document

| Field     | Example                            |
| --------- | ---------------------------------- |
| url       | `https://arxiv.org/pdf/1706.03762` |
| fileName  | `1706.03762v7.pdf`                 |
| fileType  | `pdf`                              |
| title     | `Attention Is All You Need`        |
| author    | `null`                             |
| created   | `2024-04-10`                       |
| pageCount | `15`                               |
| ocrPages  | `0`                                |
| wordCount | `5993`                             |
| sizeBytes | `2215244`                          |

#### 📝 Content

| Field    | Example                                                                                       |
| -------- | --------------------------------------------------------------------------------------------- |
| markdown | `# Attention Is All You Need\n\n### Abstract\n\nThe dominant sequence transduction models...` |
| text     | `Attention Is All You Need\n\nAbstract\n\nThe dominant sequence transduction models...`       |
| pages    | `[{"page": 1, "markdown": "# Attention Is All You Need..."}]`                                 |

#### 🧩 Chunk (chunk mode)

| Field       | Example                                                                      |
| ----------- | ---------------------------------------------------------------------------- |
| chunkIndex  | `18`                                                                         |
| chunkCount  | `38`                                                                         |
| headingPath | `Attention Is All You Need > 3 Model Architecture > 3.5 Positional Encoding` |
| tokens      | `230`                                                                        |
| text        | `In this work, we use sine and cosine functions of different frequencies...` |

### 📊 Example Output

```json
{
    "url": "https://calibre-ebook.com/downloads/demos/demo.docx",
    "fileName": "demo.docx",
    "fileType": "docx",
    "title": "DOCX Demo",
    "author": "Kovid Goyal",
    "created": "2013-06-05",
    "modified": "2013-06-20",
    "pageCount": 1,
    "pagesProcessed": 1,
    "ocrPages": 0,
    "sizeBytes": 1311881,
    "wordCount": 1648,
    "markdown": "# Demonstration of DOCX support in calibre\n\nThis document demonstrates the ability of the calibre DOCX Input plugin...\n\n# Text Formatting\n\n## Inline formatting\n\nHere is some **bold,** _italic,_ ...",
    "scrapedAt": "2026-11-16T12:00:00.000Z"
}
```

### 📋 Dataset Views

The Apify Console gives you **4 ready-made table views** to quickly browse your results:

| View                | What It Shows                                           |
| ------------------- | ------------------------------------------------------- |
| 📊 **Documents**    | URL, type, title, pages, OCR pages, words and any error |
| 📝 **Content**      | Title with the Markdown and text                        |
| 🧩 **Chunks**       | Section path, token count and text of every chunk       |
| 📋 **Full details** | Every single field, the complete dataset                |

### 💰 Pricing

Pay only for what you convert: a small fee per document, a tiny fee per page, and a separate fee only for pages that need OCR. Failed downloads and unsupported files are free.

### ❓ FAQ

**📄 Does it work with scanned PDFs?**
Yes. In **Auto** mode every page without a text layer is read with OCR. Choose the languages printed in your documents for the best accuracy.

**📊 Are tables preserved?**
Tables from Word, Excel, PowerPoint and web pages become Markdown tables. Tables inside PDFs come out as text in reading order, because PDFs do not store table structure.

**🔐 Can I convert password-protected or private files?**
Protected PDFs work with the **PDF password** option. Files must be reachable by a link: public URLs, signed links (S3, Google Cloud Storage, Dropbox) or your own server.

**🧩 What chunk size should I use for RAG?**
300 to 800 tokens with 50 to 100 tokens of overlap is a good default for most embedding models.

**📦 Is there a size limit?**
50 MB per file by default, adjustable up to 500 MB.

### 💬 Need Something Custom?

🛠️ Need Google Drive or SharePoint folders, table extraction from PDFs, embeddings pushed straight into your vector database, or a custom output schema? **Send me a private message on Apify** and I will build it for you. Feature requests and feedback are always welcome! 🙌

# Actor input Schema

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

Links to PDF, Word (.docx), PowerPoint (.pptx), Excel (.xlsx/.xls), CSV, HTML, EPUB or image files.

## `outputFormat` (type: `string`):

Markdown keeps headings, lists, tables and links. Text is plain.

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

One dataset row per document, or one row per chunk (ready for a vector database).

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

Approximate tokens per chunk. 0 = no chunks in document mode; chunk mode uses 500 when 0.

## `chunkOverlap` (type: `integer`):

Tokens repeated from the end of the previous chunk.

## `ocrMode` (type: `string`):

Auto reads scanned pages and images only. Always OCRs every PDF page. Off never runs OCR.

## `ocrLanguages` (type: `array`):

Languages printed in your scans. Fewer languages = faster and more accurate.

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

0 = all pages (PDF).

## `maxRows` (type: `integer`):

Spreadsheets and CSV. 0 = all rows.

## `includePages` (type: `boolean`):

Adds a pages array (page number + Markdown) to each document row.

## `includeSpeakerNotes` (type: `boolean`):

Adds the presenter notes under each slide.

## `pdfPassword` (type: `string`):

For password-protected PDFs.

## `maxFileSizeMb` (type: `integer`):

Larger files are skipped with an error row.

## `maxConcurrency` (type: `integer`):

How many documents are converted at the same time.

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

Only needed when the file host blocks downloads.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://arxiv.org/pdf/1706.03762"
    }
  ],
  "outputFormat": "markdown",
  "outputMode": "document",
  "chunkSize": 0,
  "chunkOverlap": 50,
  "ocrMode": "auto",
  "ocrLanguages": [
    "eng"
  ],
  "maxPages": 0,
  "maxRows": 5000,
  "includePages": false,
  "includeSpeakerNotes": true,
  "maxFileSizeMb": 50,
  "maxConcurrency": 3,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# 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 = {
    "startUrls": [
        {
            "url": "https://arxiv.org/pdf/1706.03762"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("trev0n/document-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": [{ "url": "https://arxiv.org/pdf/1706.03762" }] }

# Run the Actor and wait for it to finish
run = client.actor("trev0n/document-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": [
    {
      "url": "https://arxiv.org/pdf/1706.03762"
    }
  ]
}' |
apify call trev0n/document-to-markdown --silent --output-dataset

```

## MCP server setup

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