# Document to Markdown for AI: PDF, OCR, Word, Excel, PowerPoint (`ai_admin/document-to-markdown`) Actor

From $1 per 1,000 pages: PDF, scanned PDF and images (OCR incl. Ukrainian and Russian), DOCX, DOC, XLSX, XLS, PPTX, PPT, ODT, RTF and HTML to clean Markdown with headings and tables, plus JSON tables and RAG chunks. OCR charged only for scanned pages.

- **URL**: https://apify.com/ai_admin/document-to-markdown.md
- **Developed by:** [Andriy Kuzmenko](https://apify.com/ai_admin) (community)
- **Categories:** AI, Developer tools, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 converted pages

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: PDF, OCR, Word, Excel, PowerPoint

Turn any business document into clean Markdown, JSON tables and RAG-ready chunks — one Actor for PDF, scanned PDF,
images, DOCX/DOC, XLSX/XLS, PPTX/PPT, ODT/ODS/ODP, RTF and HTML.

- **Every common format in one place.** Modern and legacy Office files (DOC, XLS, PPT, RTF, OpenDocument) are converted too.
- **OCR only where it is needed.** Pages with a text layer are read directly. Scanned pages and images go through
  Tesseract OCR in 11 languages, including **Ukrainian and Russian** (Cyrillic) as well as English, German, French,
  Spanish, Italian, Portuguese, Polish, Dutch and Czech.
- **Structure kept for LLMs.** Headings (`#`, `##`), lists and tables as Markdown, every table also as JSON rows,
  optional chunks with their nearest heading for vector databases.

Spreadsheet cells keep their values exactly: text stays text (`96.50` is not turned into `96.5`), numbers follow the
cell's number format (`1,234.50`).

### Why this Actor

| | This Actor | Typical alternatives in the Apify Store (Oct 2026) |
|---|---|---|
| **Price** | **$1 per 1,000 text pages, $4 per 1,000 OCR pages** — you pay per page, OCR only for scanned pages | $3–5 per 1,000 PDFs plus $15–20 per 1,000 OCR pages |
| **Formats** | PDF, scans, images, DOCX/DOC, XLSX/XLS, PPTX/PPT, ODT/ODS/ODP, RTF, HTML — one Actor | Mostly PDF only; Office files need another tool |
| **Structure** | Headings, lists, tables as Markdown **and** JSON rows, RAG chunks with their heading | Often plain text, tables lost |
| **Cyrillic** | Ukrainian and Russian OCR built in | English-first OCR |

### Input

```json
{
  "sources": [
    { "url": "https://example.com/report.pdf" },
    { "url": "https://example.com/contract.docx" }
  ],
  "ocrMode": "auto",
  "ocrLanguages": ["eng", "ukr"],
  "includeTables": true,
  "chunkSize": 1500
}
```

| Field | Meaning |
|---|---|
| `sources` | Document URLs. Files in your own Apify key-value store work too: set the store's access to "Anyone with ID can read" and use `https://api.apify.com/v2/key-value-stores/<store ID>/records/<key>` (the Actor runs with limited permissions and does not use your token). |
| `ocrMode` | `auto` (scanned pages only), `always`, `never` |
| `ocrLanguages` | Languages expected in scans and images |
| `includeTables` | Return tables as JSON rows (header first) |
| `chunkSize` | Characters per RAG chunk, `0` = no chunks |
| `maxPagesPerDocument` | Pages beyond the limit are skipped and not charged |

### Output

One dataset item per document:

```json
{
  "url": "https://example.com/report.pdf",
  "fileName": "report.pdf",
  "format": "pdf",
  "sourcePages": 3,
  "textPages": 2,
  "ocrPages": 1,
  "characters": 5120,
  "metadata": { "title": "Quarterly Supply Report", "author": "..." },
  "markdown": "# Quarterly Supply Report\n\nThe warehouse in Lviv received 1,240 pallets...\n\n| Item | Quantity | Price |\n| --- | --- | --- |\n| Cement | 420 | 96.50 |",
  "tables": [[["Item", "Quantity", "Price"], ["Cement", "420", "96.50"]]],
  "chunks": [{ "index": 0, "heading": "Quarterly Supply Report", "text": "..." }],
  "warnings": [],
  "seconds": 1.4
}
```

A document that cannot be downloaded or read gets an `error` field instead and is **not charged**.
Markdown longer than 4 million characters is stored in full in the run's key-value store (`markdownKey`).

### Pricing

Pay per event — you pay only for converted pages:

| Event | Price | What counts |
|---|---|---|
| `page` | **$1 per 1,000** | a PDF page read from its text layer; for Office, HTML and text files — every 3,000 characters of output (at least 1 per document) |
| `ocr-page` | **$4 per 1,000** | a scanned PDF page or an image frame read with OCR |

Plus Apify's standard start fee of $0.05 per 1,000 runs. Failed documents and skipped pages are not charged, and pages
with a text layer or blank pages are never charged as OCR. The run stops before it
would exceed your maximum charge per run.

### Use with AI agents and code

- **MCP (Claude, Cursor, VS Code, any MCP client):** add `https://mcp.apify.com?tools=ai_admin/document-to-markdown` as an MCP server —
  the agent gets one tool with this Actor's input schema and pays per use through your Apify account.
- **One HTTP call that returns the results:**

```bash
curl -X POST "https://api.apify.com/v2/acts/ai_admin~document-to-markdown/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"sources": [{"url": "https://api.apify.com/v2/key-value-stores/FloomuI2DrQCJazY8/records/text-en.pdf"}, {"url": "https://api.apify.com/v2/key-value-stores/FloomuI2DrQCJazY8/records/doc-uk.docx"}], "ocrMode": "auto", "ocrLanguages": ["eng", "ukr"], "includeTables": true}'
```

- **Agentic payments:** the Actor is enabled for Apify's agentic payments (x402), so autonomous agents can pay per run.

Open source: [github.com/AndriyVK/-apify-document-tools](https://github.com/AndriyVK/-apify-document-tools)

### Limits

- Tables are detected in PDFs with a text layer and in Office/HTML files. Tables in scanned pages come out as OCR text.
- RTF files keep no heading styles, so their headings arrive as plain paragraphs.
- Password-protected files are not supported. Maximum download size is 200 MB.

### Feedback

Found a document that converts badly? Open an issue with a link to a sample (or a similar public file) — fixes for real
documents get priority.

# Actor input Schema

## `sources` (type: `array`):

Public URLs of the documents (PDF, scanned PDF, PNG/JPG/TIFF, DOCX, DOC, XLSX, XLS, PPTX, PPT, ODT, ODS, ODP, RTF, HTML, CSV, TXT). Files in your own Apify key-value store work too: set the store's access to "Anyone with ID can read" and use https://api.apify.com/v2/key-value-stores/<store ID>/records/<key>.

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

auto: OCR only pages without a text layer (scans). always: OCR every PDF page. never: text layer only.

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

Languages expected in scans and images. More languages are slightly slower.

## `includeTables` (type: `boolean`):

Also return every table as rows of cells (header row first).

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

Split the Markdown into chunks of at most this many characters, each with its nearest heading. 0 = no chunks.

## `maxPagesPerDocument` (type: `integer`):

Pages beyond this limit are skipped (and not charged).

## Actor input object example

```json
{
  "sources": [
    {
      "url": "https://api.apify.com/v2/key-value-stores/FloomuI2DrQCJazY8/records/text-en.pdf"
    }
  ],
  "ocrMode": "auto",
  "ocrLanguages": [
    "eng"
  ],
  "includeTables": true,
  "chunkSize": 0,
  "maxPagesPerDocument": 500
}
```

# Actor output Schema

## `documents` (type: `string`):

Dataset items with markdown, tables, chunks, textPages, ocrPages, metadata, warnings or error for every document URL.

## `fullMarkdown` (type: `string`):

Key-value store records markdown-NNNNN with the complete Markdown when it exceeds 4 million characters.

# 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 = {
    "sources": [
        {
            "url": "https://api.apify.com/v2/key-value-stores/FloomuI2DrQCJazY8/records/text-en.pdf"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("ai_admin/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 = { "sources": [{ "url": "https://api.apify.com/v2/key-value-stores/FloomuI2DrQCJazY8/records/text-en.pdf" }] }

# Run the Actor and wait for it to finish
run = client.actor("ai_admin/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 '{
  "sources": [
    {
      "url": "https://api.apify.com/v2/key-value-stores/FloomuI2DrQCJazY8/records/text-en.pdf"
    }
  ]
}' |
apify call ai_admin/document-to-markdown --silent --output-dataset

```

## MCP server setup

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