# Document to Markdown for AI & RAG — PDF, DOCX, PPTX, XLSX, OCR (`jeggy/document-to-markdown`) Actor

Convert PDFs, Word, PowerPoint, Excel, HTML, EPUB, CSV and images into clean, LLM-ready Markdown with real tables, headings, correct multi-column reading order, page markers, OCR for scans and ready-made RAG chunks. Pay per page. MCP-ready for AI agents.

- **URL**: https://apify.com/jeggy/document-to-markdown.md
- **Developed by:** [Jeggy](https://apify.com/jeggy) (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.00 / 1,000 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?

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 for AI & RAG — PDF, DOCX, PPTX, XLSX, OCR

**PDF to Markdown, plus Word, PowerPoint and Excel: send document URLs and get clean, LLM-ready Markdown and RAG chunks back.** It handles PDFs (including **scanned PDFs with OCR**), DOCX, PPTX, XLSX, HTML, EPUB, CSV, JSON, TXT and images. It produces real Markdown **tables**, a proper **heading hierarchy**, the **correct reading order for two-column papers**, page markers for citations, and chunks that never cut a table in half. **$0.001 per document + $0.0001 per page** ($0.0015 per OCR page).

It's built for **RAG pipelines, AI agents (Claude, ChatGPT and Cursor via Apify MCP), n8n, Make and Zapier automations**, and anyone tired of PDF parsers that silently scramble or drop content.

### Why this one

Popular quick converters return **nothing for scanned pages**, **interleave two-column text line by line** and **flatten tables**. Those are exactly the chunks your retriever needs. This Actor fixes all three:

| Problem | What this Actor does |
|---|---|
| Scanned or image-only pages come back empty | **Auto-OCR** (Tesseract) runs only on pages with no text layer, so you pay for OCR only when it's needed |
| Two-column papers turn into word salad | **Column-gutter detection** reads the left column, then the right, with full-width titles kept in place |
| Tables flattened into one value per line | **Markdown pipe tables**, with empty merged columns removed |
| Headings lost, so chunking by section fails | Headings from **font size, bold weight and section numbers** (1, 2.1, 3.2.1…) become `#`, `##`, `###` |
| Chunks cut tables or lose context | **Heading-aware chunks** with token estimates, page ranges, a heading path and `hasTable`. Big tables split by rows with the header repeated |
| Huge payloads choke n8n or Make | Optional fields (`includeMarkdown`, `includePages`), plus chunks that are ready to embed |

### Supported inputs

PDF (text, scanned or mixed, plus password-protected with a password) · DOCX · PPTX (one page per slide) · XLSX · HTML · EPUB · CSV · JSON · XML · TXT/MD · PNG, JPG, TIFF, WebP, GIF and BMP images (OCR). OCR languages: English, German, French, Spanish, Italian, Portuguese and Dutch (`eng+deu`…).

### Input example

```json
{
  "urls": [
    "https://arxiv.org/pdf/1706.03762",
    "https://calibre-ebook.com/downloads/demos/demo.docx",
    "https://raw.githubusercontent.com/ocrmypdf/OCRmyPDF/main/tests/resources/linn.pdf"
  ],
  "chunkSizeTokens": 800,
  "chunkOverlapTokens": 80,
  "ocrMode": "auto",
  "ocrLanguages": "eng"
}
```

### Output example (one item per document)

```json
{
  "url": "https://arxiv.org/pdf/1706.03762",
  "fileName": "1706.03762v7.pdf",
  "contentType": "application/pdf",
  "fileType": "pdf",
  "title": "Attention Is All You Need",
  "pageCount": 15,
  "pagesProcessed": 15,
  "truncated": false,
  "ocrPages": 0,
  "billedPages": 15,
  "words": 6851,
  "tables": 9,
  "tokenEstimate": 10982,
  "metadata": {
    "creator": "LaTeX with hyperref",
    "producer": "pdfTeX-1.40.25",
    "created": "D:20240410211143Z",
    "modified": "D:20240410211143Z"
  },
  "markdown": "<!-- page 1 -->\n\nProvided proper attribution is provided, Google hereby grants permission to reproduce the tables and figures in this paper solely for use in journalistic or scholarly works.\n\n# Attention Is All You Need\n\nAshish Vaswani ∗ Noam Shazeer ∗ Niki Parmar ∗ Jakob Uszkoreit ∗ Google Brain Google Brain Google Research Google Research avaswani@google.com noam@google.com nikip@google.com usz@google.com\n\nLlion Jo …",
  "chunks": [
    {
      "index": 3,
      "text": "## 3 Model Architecture\n\nMost competitive neural sequence transduction models have an encoder-decoder structure [5, 2, 35]. Here, the encoder maps an input sequence of symbol representations ( x , ..., x ) to a sequence 1 n of continuous representations z = (  …",
      "tokens": 538,
      "heading": "Attention Is All You Need > 3 Model Architecture",
      "pageStart": 2,
      "pageEnd": 3,
      "hasTable": false
    },
    "…"
  ],
  "processingMs": 3723
}
```

A failed document is free:

```json
{
  "url": "http://127.0.0.1/secret.pdf",
  "error": "Refusing to fetch non-public address 127.0.0.1"
}
```

### Pricing (pay per event)

| Event | Price | Notes |
|---|---|---|
| `document` | **$0.001** | per document converted successfully |
| `page` | **$0.0001** | per PDF page or PPTX slide. Other formats count 1 page per 3,000 characters of output |
| `ocr-page` | **$0.0015** | extra, only for pages that actually needed OCR |

Examples: a 15-page research paper costs **$0.0025**, a 100-page text PDF costs **$0.011**, a single scanned image costs **$0.0026**, and a 10-page scan costs **$0.017**. There's no per-run start fee beyond Apify's standard $0.00005. Failed downloads, unsupported files and errors are **never charged**, and Apify platform usage is included. Before converting each document, the Actor checks that it fits within your "Maximum cost per run".

### How it compares

Figures below are from Apify Store listings (November 2026). They can change.

| | This Actor | `memo23/pdf-text-extractor` (most-used PDF-to-Markdown style rival) |
|---|---|---|
| Price | **$0.001 per document + $0.0001 per page**; **$0.0015** per OCR page. Platform usage included. | **$0.005** actor start + **$0.005** per PDF + **$0.015** per OCR page. |
| Users (30 days, Nov 2026) | New | 191 monthly users; 5.00★ from 2 reviews |

A 20-page text PDF on this Actor costs **$0.003** ($0.001 + 20 × $0.0001). The same size on that rival is **$0.010** before any OCR.

### Use with AI agents (MCP) and automations

- **MCP:** connect `https://mcp.apify.com` in Claude Desktop, Cursor or VS Code and add this Actor. Then ask: *"Read this PDF and summarise section 3"*.
- **n8n, Make and Zapier:** call the Actor with the URL of an email attachment or cloud file and use `chunks[].text` directly in your embedding step.
- **LangChain and LlamaIndex:** load the dataset with the Apify integration and map `chunks` to documents, using `pageStart` and `heading` as metadata.

### FAQ

**Does it work on scanned PDFs?** Yes. With `ocrMode: auto`, any page without a text layer is OCR'd at 300 dpi. Use `always` to force OCR, for example on PDFs with a broken text layer.

**How accurate are tables?** Tables with ruling lines (most business and financial PDFs) come out as clean Markdown tables. Borderless, academic-style tables are harder: their text is kept, but the cell structure may be approximate.

**Can I upload files instead of URLs?** Use any direct-download URL, such as an S3 or Dropbox direct link, a public Google Drive export link, or an Apify key-value store record URL.

**Is my data stored?** Files are processed in a temporary folder and deleted at the end of the run. Output stays in your own Apify dataset.

**Limits?** Up to 200 MB and 2,000 pages per document (the defaults are 50 MB and 300 pages). Legacy .doc, .xls and .ppt aren't supported, so save them as DOCX, XLSX, PPTX or PDF.

**Is there an AGPL or commercial licence issue?** No. It uses only permissive libraries: pdfplumber (MIT), pypdfium2 (Apache/BSD), Tesseract (Apache-2.0) and Microsoft MarkItDown (MIT).

### Changelog

- **1.0**: first release. Auto-OCR, two-column reading order, tables, heading detection, RAG chunks, page markers, pay per page.

### Related tools

Other tools in this collection:

- [Website Screenshot API](https://apify.com/jeggy/website-screenshot-api) — Full-page, mobile and PDF screenshots with cookie banners removed. $1.80 per 1,000.
- [ATS Jobs API & Hiring Signals](https://apify.com/jeggy/ats-jobs-hiring-signals) — Greenhouse, Lever, Ashby and other career boards, plus hiring signals. $0.40 per 1,000 jobs.
- [App Store & Google Play Reviews Scraper](https://apify.com/jeggy/app-reviews-scraper) — Reviews from both stores in one table. $0.08 per 1,000 reviews.
- [Shopify & WooCommerce Products Scraper](https://apify.com/jeggy/shopify-woocommerce-products) — Prices, variants and stock, with a price-drop monitor. $0.40 per 1,000 products.
- [Bulk Domain Lookup](https://apify.com/jeggy/domain-intel) — WHOIS/RDAP, DNS, SPF, DMARC and SSL in one row. $0.80 per 1,000 domains.
- [Tech Stack Detector](https://apify.com/jeggy/tech-stack-detector) — BuiltWith / Wappalyzer-style detection, 7,700+ fingerprints. $1 per 1,000 sites.
- [Sitemap URL Extractor](https://apify.com/jeggy/sitemap-url-extractor) — Every page URL from a site's sitemaps. $0.15 per 1,000 URLs.

# Actor input Schema

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

Direct links to files: PDF, DOCX, PPTX, XLSX, HTML, EPUB, CSV, JSON, TXT, or images (PNG, JPG, TIFF, WebP) for OCR. Google Drive/Dropbox links must be direct-download links.

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

Split the Markdown into heading-aware chunks for RAG/embeddings. Tables are kept whole (or split by rows with the header repeated). 0 = no chunks.

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

Approximate tokens of overlap repeated between consecutive chunks to preserve context.

## `includeMarkdown` (type: `boolean`):

Include the full document Markdown in the output item. Turn off to only get chunks (smaller payloads).

## `includePageMarkers` (type: `boolean`):

Adds  comments so answers can cite page numbers.

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

Also output an array with the Markdown of each page/slide separately.

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

auto = OCR only pages without a text layer (recommended); always = OCR every page; off = never OCR.

## `ocrLanguages` (type: `string`):

Tesseract codes joined with '+': eng, deu, fra, spa, ita, por, nld. Example: 'eng+deu'.

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

Only the first N pages of each document are processed (and billed).

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

For encrypted PDFs. Stored as a secret.

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

Files larger than this are skipped without charge.

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

How many documents are converted in parallel.

## Actor input object example

```json
{
  "urls": [
    "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
  ],
  "chunkSizeTokens": 800,
  "chunkOverlapTokens": 80,
  "includeMarkdown": true,
  "includePageMarkers": true,
  "includePages": false,
  "ocrMode": "auto",
  "ocrLanguages": "eng",
  "maxPages": 300,
  "maxFileSizeMb": 50,
  "maxConcurrency": 3
}
```

# Actor output Schema

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

One item per input URL: title, fileType, pageCount, ocrPages, tables, tokenEstimate, markdown, chunks\[] or error.

# 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://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("jeggy/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 = { "urls": ["https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"] }

# Run the Actor and wait for it to finish
run = client.actor("jeggy/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 '{
  "urls": [
    "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
  ]
}' |
apify call jeggy/document-to-markdown --silent --output-dataset

```

## MCP server setup

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