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

Convert PDF, Word, PowerPoint, Excel, CSV, web pages and EPUB to clean Markdown for LLMs, RAG and AI agents. Keeps headings and tables, adds metadata and token counts, and splits documents into RAG-ready chunks with heading paths. Accepts Google Drive and Dropbox links.

- **URL**: https://apify.com/weav3rx/document-to-markdown.md
- **Developed by:** [Roman Golovko](https://apify.com/weav3rx) (community)
- **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 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: PDF, Word, PowerPoint, Excel

**Turn any document into clean Markdown that LLMs understand, in one run.** PDF, Word (DOCX), PowerPoint (PPTX), Excel (XLSX), CSV, web pages (HTML) and EPUB books come out as tidy Markdown with real headings and tables, plus metadata, word and token counts. Switch on **RAG chunks** and every document is split into ready-to-embed chunks, each labeled with where it sits in the document (e.g. `Model Architecture > Attention > Multi-Head Attention`).

Built for AI agents, chatbots over your documents, RAG pipelines and anyone who needs text out of files without copy-pasting.

### Why this one

- 📚 **8 formats, one Actor.** PDF, DOCX, PPTX, XLSX, CSV, HTML, EPUB, TXT/MD. No juggling a different tool per file type.
- 🧱 **Structure is kept.** Headings stay headings (also numbered sections like `3.2 Attention` in PDFs), Excel sheets and Word/PowerPoint tables become Markdown tables, PowerPoint slides keep their titles and speaker notes.
- 🧹 **Clean PDF text.** Lines are joined into paragraphs, hyphenated words repaired, page numbers and repeated headers/footers removed, side stamps ignored.
- ✂️ **Smart RAG chunks.** Chunks never cut a table row (long tables repeat their header in every chunk), a heading always stays with its text, and overlap carries only running text.
- 🔗 **Paste share links.** Google Drive, Google Docs/Sheets/Slides, Dropbox and GitHub links are turned into direct downloads automatically. You can also upload a file.
- 🔎 **Format detected from the file itself**, not just the extension, so mislabeled files still work.
- 💸 **Pay only for converted documents.** Unreachable links, unsupported files and scanned PDFs without a text layer are reported but never charged.

### What you get per document

| Field | Description |
|---|---|
| `markdown` | The document as clean Markdown |
| `title`, `author`, `createdAt` | From the file's metadata (or the first heading) |
| `pages` / `slides` / `sheets` / `chapters` | Size of the document |
| `wordCount`, `charCount`, `approxTokens` | For budgeting LLM context |
| `tables` | Number of tables found |
| `warnings` | E.g. scanned pages without text, cut sheets |
| `status` | `ok`, `no_text`, `unsupported` or `error` (with `error` message) |

In **RAG chunks** mode you get one item per chunk with `text`, `headingPath`, `chunkIndex`, `chunkCount`, `charCount` and `approxTokens`.

### Example (chunks mode)

```json
{
  "url": "https://arxiv.org/pdf/1706.03762",
  "format": "pdf",
  "title": "Attention Is All You Need",
  "chunkIndex": 5,
  "chunkCount": 18,
  "headingPath": ["3 Model Architecture", "3.2 Attention", "3.2.2 Multi-Head Attention"],
  "text": "### 3.2.2 Multi-Head Attention\n\nInstead of performing a single attention function...",
  "charCount": 2398,
  "approxTokens": 600
}
```

### How to use

1. Paste document links (one per line) or upload a file.
2. Choose *One item per document* or *RAG chunks* (set the chunk size; 4,000 characters ≈ 1,000 tokens).
3. Run. Send the results to your vector database, LLM workflow, Make, Zapier, n8n or download as JSON/CSV.

### Good to know

- **Scanned PDFs** (images of pages) have no text layer. They are reported with status `no_text` and are not charged. OCR is not included.
- **Old binary Office files** (.doc, .xls, .ppt) are not supported: save them as .docx/.xlsx/.pptx or PDF.
- **PDF tables** come out as text lines, because PDFs don't store tables as tables. Word, PowerPoint and Excel tables are converted to real Markdown tables.
- Files must be reachable by a link (public or shared), or uploaded. Max size is configurable (default 50 MB).

### FAQ

**Is my document stored?** It is processed in your own Apify run, and the result is saved only in your run's dataset.

**How are tokens counted?** `approxTokens` is characters ÷ 4, a good estimate for GPT and Claude tokenizers on English text.

**Can I convert a whole website?** This Actor converts the pages you list. To crawl a site first, run a crawler and pass the page URLs here.

Missing a format or found a bug? Open an issue on the **Issues** tab.

# Actor input Schema

## `documentUrls` (type: `array`):

Public links to documents, one per line: PDF, DOCX, PPTX, XLSX, CSV, HTML pages, EPUB, TXT or MD. Google Drive, Google Docs/Sheets/Slides, Dropbox and GitHub share links are converted to direct downloads automatically.

## `uploadedFile` (type: `string`):

Upload one document from your computer instead of (or in addition to) URLs.

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

One item per document with the full Markdown, or one item per chunk ready for a vector database. The price is per document either way.

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

Target maximum characters per chunk (about 4 characters = 1 token). Used only in RAG chunks mode.

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

Characters of running text repeated at the start of the next chunk for context. Tables and headings are never split or repeated.

## `htmlMainContentOnly` (type: `boolean`):

For HTML pages, keep the article and drop menus, sidebars, cookie banners and footers.

## `maxPagesPerPdf` (type: `integer`):

PDF pages beyond this number are skipped (a warning tells you).

## `maxRowsPerSheet` (type: `integer`):

Spreadsheet sheets and CSV files are cut after this many rows (a warning tells you).

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

Larger files are skipped with an error and not charged.

## Actor input object example

```json
{
  "documentUrls": [
    "https://arxiv.org/pdf/1706.03762",
    "https://en.wikipedia.org/wiki/Markdown"
  ],
  "outputMode": "document",
  "chunkSize": 4000,
  "chunkOverlap": 200,
  "htmlMainContentOnly": true,
  "maxPagesPerPdf": 500,
  "maxRowsPerSheet": 5000,
  "maxFileSizeMb": 50
}
```

# Actor output Schema

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

Per document: status, format, title, author, created date, pages/slides/sheets, word count, approximate tokens, number of tables, warnings and the Markdown (or, in chunks mode, one item per chunk with its heading path).

# 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 = {
    "documentUrls": [
        "https://arxiv.org/pdf/1706.03762",
        "https://en.wikipedia.org/wiki/Markdown"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("weav3rx/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 = { "documentUrls": [
        "https://arxiv.org/pdf/1706.03762",
        "https://en.wikipedia.org/wiki/Markdown",
    ] }

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

```

## MCP server setup

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