# PDF, Word, PowerPoint & Excel to Markdown for LLM and RAG (`plainrecordlabs/docs-to-markdown`) Actor

Turn PDF, DOCX, PPTX, XLSX and HTML files into clean Markdown for AI pipelines. Ruled PDF tables become Markdown tables, with optional RAG chunks. Give it URLs, get one row per document.

- **URL**: https://apify.com/plainrecordlabs/docs-to-markdown.md
- **Developed by:** [Plain Record Labs](https://apify.com/plainrecordlabs) (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 $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.
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

## PDF, Word, PowerPoint & Excel to Markdown for LLM and RAG

Turn documents into clean Markdown your AI pipeline can use. Give it links to PDF, DOCX, PPTX, XLSX, HTML, CSV or
text files and get one row per document with its Markdown, page and table counts, and optional chunks ready for
embedding.

Paste a few document links and press Start.

### What people use it for

- **RAG and AI agents:** feed documents into a vector store or an LLM as Markdown instead of messy raw text.
- **Search and knowledge bases:** convert a folder of reports, decks and spreadsheets into one format.
- **Data teams:** pull the text and the ruled tables out of PDFs without opening them.

### What it handles

| File | How it converts |
|---|---|
| **PDF** | Text page by page. Tables drawn with ruling lines become Markdown tables. |
| **Word (DOCX)** | Headings, paragraphs, lists and tables. |
| **PowerPoint (PPTX)** | Slide titles and text, in slide order. |
| **Excel (XLSX)** | Each sheet as a Markdown table. |
| **HTML, CSV, text** | Cleaned to Markdown. |

### What it does not do

- It does not read scanned pages. A page that is only an image has no text layer, so it comes back empty and is
  listed in `pagesWithoutText`.
- Tables drawn without lines in a PDF come through as aligned text, not as a Markdown table.
- PDF headings are not detected, so PDF text comes back as paragraphs.
- Password-protected files are not supported.

### Input

| Field | What it does |
|---|---|
| **Document URLs** | Direct links to the files. Sites whose robots.txt disallows automated access are skipped. |
| **Add RAG chunks** | Also returns the Markdown split into chunks at paragraph boundaries. |
| **Chunk size** and **Chunk overlap** | Characters per chunk and how much carries over. |
| **Mark PDF page breaks** | Puts a `<!-- page N -->` comment before each PDF page. |
| **Max PDF pages per document** | A cap on pages converted, and so on cost. |
| **Max file size (MB)** | Larger files are skipped. |

### Output

One item per converted document:

```json
{
  "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
  "fileName": "fw9.pdf",
  "fileType": "pdf",
  "title": "Form W-9 (Rev. March 2024)",
  "pageCount": 6,
  "pagesConverted": 6,
  "pagesWithoutText": [],
  "tableCount": 1,
  "charCount": 37929,
  "wordCount": 6311,
  "markdown": "Form W-9 Request for Taxpayer Identification Number and Certification ...",
  "chunks": [{ "index": 0, "text": "..." }]
}
```

The example values are illustrative. Files that could not be converted are not charged and are listed with the reason
in the run's `SUMMARY` record.

### Privacy

Your files are fetched only for your run and converted in memory. Nothing is kept outside your own run's storage.

### FAQ

**How do I convert a PDF to Markdown for an LLM or RAG?**
Paste the PDF link into **Document URLs** and press Start. Turn on **Add RAG chunks** to also get the text split into
overlapping chunks ready to embed in a vector store.

**Does it keep tables?**
Tables in Word and Excel files, and PDF tables drawn with ruling lines, come back as Markdown tables. PDF tables
without lines come through as aligned text.

**Can it convert scanned PDFs?**
No. It does not run OCR, so a page that is only an image comes back empty and is listed in `pagesWithoutText`.

**Can I convert Word, PowerPoint and Excel files too?**
Yes. DOCX, PPTX, XLSX, HTML, CSV and text files all convert to Markdown in the same run.

**Can I call it from an API or an AI agent?**
Yes. Like any Apify Actor it runs from the Apify API, the Python and JavaScript clients, or an integration, and
returns one row per document.

### Pricing

You pay per document converted, plus a small charge per PDF page. Word, PowerPoint, Excel and HTML files have no page
charge. The prices are on the Pricing tab. **Max PDF pages per document** caps what one document can cost.

### Feedback

Need another file type or a fix? Open an issue on the Issues tab.

# Actor input Schema

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

Direct links to PDF, DOCX, PPTX, XLSX, HTML, CSV or text files. Sites whose robots.txt disallows automated access are skipped.

## `chunks` (type: `boolean`):

Also split each document's Markdown into chunks at paragraph boundaries, ready for embedding.

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

Target characters per chunk.

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

Characters carried over from the end of one chunk to the start of the next.

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

Insert a  comment before each PDF page.

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

Convert at most this many pages of each PDF. You pay per page converted.

## `maxFileMb` (type: `integer`):

Larger files are skipped and listed in the run summary.

## Actor input object example

```json
{
  "urls": [
    {
      "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
    }
  ],
  "chunks": false,
  "chunkSize": 2000,
  "chunkOverlap": 200,
  "pageMarkers": false,
  "maxPages": 200,
  "maxFileMb": 50
}
```

# Actor output Schema

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

One item per converted document, with its Markdown.

## `summary` (type: `string`):

Counts, plus each document that could not be converted and why.

# 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": [
        {
            "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("plainrecordlabs/docs-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": [{ "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf" }] }

# Run the Actor and wait for it to finish
run = client.actor("plainrecordlabs/docs-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": [
    {
      "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
    }
  ]
}' |
apify call plainrecordlabs/docs-to-markdown --silent --output-dataset

```

## MCP server setup

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