# Document to Markdown for AI — PDF, Word, PowerPoint, Excel, Web (`keel-data/document-to-markdown`) Actor

Convert PDF, DOCX, PPTX, XLSX, CSV and web pages to clean Markdown for LLMs, RAG and AI agents. Keeps headings, lists and tables, adds word and token counts, and can split text into chunks. Google Drive, Docs and Dropbox links work.

- **URL**: https://apify.com/keel-data/document-to-markdown.md
- **Developed by:** [Keel Data](https://apify.com/keel-data) (community)
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.50 / 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.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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 and web pages

Turn documents into **clean Markdown that LLMs understand**. Paste links to PDFs, Word files, slide decks, spreadsheets or web pages and get structured Markdown with headings, lists and tables kept. You also get word and token counts, and optional ready-to-embed **chunks for RAG**.

Works with **Google Drive, Google Docs/Slides/Sheets and Dropbox share links**.

### Supported formats

| Format | What is kept |
|---|---|
| **PDF** | Headings (detected from font size), paragraphs, bullet and numbered lists, re-joined hyphenated words, optional page markers, title and author |
| **Word (.docx)** | Headings, bold/italic, lists, tables, links |
| **PowerPoint (.pptx)** | One section per slide with its title and bullets, plus speaker notes |
| **Excel (.xlsx)** | One Markdown table per sheet |
| **Web pages** | Main article only (menus, ads and footers removed), absolute links |
| **CSV, TXT, Markdown, JSON** | Tables, cleaned text, pretty JSON |

Scanned PDFs without a text layer are flagged with `needsOcr: true` and **not charged**.

### Output

```json
{
  "status": "ok",
  "url": "https://arxiv.org/pdf/1706.03762",
  "fileType": "pdf",
  "title": "Attention Is All You Need",
  "markdown": "## Attention Is All You Need\n\nAbstract\n\nThe dominant sequence transduction models...",
  "chunks": ["## Attention Is All You Need\n\n...", "..."],
  "wordCount": 6230,
  "tokensEstimate": 10950,
  "pageCount": 15,
  "needsOcr": false,
  "metadata": { "author": null, "createdAt": "D:20240410211143Z" },
  "warnings": []
}
```

### How to use it

1. Paste one or more **document URLs** (public links).
2. Optional: set a **chunk size** (for example 2000 characters) to get chunks for embeddings.
3. Run, then download the results as JSON or CSV, or send them to your vector database, LangChain, LlamaIndex, Make, Zapier or n8n.

AI agents can call this actor through the **Apify MCP server** to read any document by URL.

### Pricing

You pay **per document converted**, whatever its size (up to the page and size limits you set).

- Failed downloads, unsupported files and scanned PDFs with no text are **free**.
- Set a maximum cost per run in the run options; the actor stops cleanly at that limit.

### Use cases

- **RAG and chatbots:** load manuals, policies and reports into a knowledge base.
- **AI agents:** let an assistant read PDFs, decks and spreadsheets from a link.
- **Content and research teams:** pull clean text out of reports and slide decks.
- **Data pipelines:** normalise mixed document collections into one text format.

### Limits

- Only public links. Files behind a login cannot be downloaded.
- Web pages are fetched without running JavaScript; pages that build their content in the browser may come back thin.
- Old binary formats (.doc, .ppt, .xls) are not supported; save them as .docx, .pptx or .xlsx.
- Text inside images is not read (no OCR yet).

### Support

Found a document that converts badly? Open an issue on the **Issues** tab with the link. We reply within one business day and use these reports to improve the converter.

# Actor input Schema

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

Public links to PDF, DOCX, PPTX, XLSX, CSV, TXT, JSON files or web pages. Google Drive, Google Docs/Slides/Sheets and Dropbox share links are converted automatically (they must be shared publicly).

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

Also split each document into chunks of about this many characters for RAG and embeddings (e.g. 2000). 0 = no chunks. Chunks follow headings and paragraphs.

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

Characters repeated from the end of one chunk at the start of the next.

## `mainContentOnly` (type: `boolean`):

Remove menus, footers, ads and sidebars from web pages and keep the article.

## `includeImages` (type: `boolean`):

Keep image links in the Markdown. Off by default because images add noise for LLMs.

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

Add each slide's speaker notes below the slide.

## `pageMarkers` (type: `boolean`):

Insert  comments so you can cite page numbers.

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

Convert at most this many pages of each PDF.

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

Skip files larger than this.

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

How many documents to process at the same time.

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

Only needed if a site blocks downloads.

## Actor input object example

```json
{
  "urls": [
    "https://arxiv.org/pdf/1706.03762"
  ],
  "chunkSize": 0,
  "chunkOverlap": 0,
  "mainContentOnly": true,
  "includeImages": false,
  "includeSpeakerNotes": true,
  "pageMarkers": false,
  "maxPages": 500,
  "maxFileSizeMb": 50,
  "maxConcurrency": 4
}
```

# Actor output Schema

## `overview` (type: `string`):

One row per document with its Markdown, word and token counts, and optional chunks.

## `runStats` (type: `string`):

Requests, retries and counts of delivered and failed items for this run.

# 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://arxiv.org/pdf/1706.03762"
    ]
};

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

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

```

## MCP server setup

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