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

Convert PDF, DOCX, XLSX, PPTX, HTML and CSV files from links into clean Markdown, JSON tables and RAG-ready chunks. Headings, lists and tables kept. Pay per page.

- **URL**: https://apify.com/docsmith/document-to-markdown.md
- **Developed by:** [Docsmith Tools](https://apify.com/docsmith) (community)
- **Categories:** AI, Developer tools
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 pages converted

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/actors/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: PDF, Word, Excel & PowerPoint for AI/RAG

Turn documents into clean **Markdown**, **JSON tables** and **RAG-ready chunks** in one step. Give it links to PDF, Word (DOCX), Excel (XLSX), PowerPoint (PPTX), HTML, CSV, TXT or MD files. You get structured output that you can drop into an LLM prompt, a vector database or a spreadsheet.

### Why use it

- **One tool for every office format.** There's no need for separate PDF, Word and Excel converters.
- **Structure is kept.** Headings, bullet lists and tables come through as real Markdown, not one block of text. PDF headings are detected from font sizes.
- **RAG-ready.** Optional chunks that respect headings, with overlap you can configure, for embeddings and vector stores.
- **Spreadsheets as data.** Each Excel sheet or CSV is returned as JSON rows keyed by its header row, plus a Markdown table.
- **You only pay for what converts.** Failed downloads and unsupported files are never charged.
- **No AI model and no scraping.** It's fast, predictable and private. Your files are processed in your own run and not stored anywhere else.

### Input

| Field | What it does |
| --- | --- |
| Document links | Direct download links to your files (S3, Google Cloud Storage, Dropbox `?dl=1`, public URLs). |
| Split into chunks for RAG | Adds a `chunks` array (on by default). |
| Chunk size / overlap | Characters per chunk (default 2,000) and overlap (default 200). |
| Include spreadsheet tables as JSON | JSON rows for XLSX/CSV (on by default). |
| Include plain text | Adds a `text` field without Markdown. |
| Max pages per PDF | Converts only the first N pages, to cap cost. |
| Max rows per sheet | Limits rows per sheet (default 1,000). |

### Output (one dataset item per document)

```json
{
  "url": "https://example.com/report.pdf",
  "success": true,
  "fileType": "pdf",
  "title": "Annual Report 2026",
  "pages": 12,
  "characters": 38211,
  "markdown": "<!-- page 1 -->\n\n# Annual Report 2026\n\n## Summary\n\nRevenue grew ...",
  "chunks": [{ "index": 0, "heading": "Summary", "text": "...", "chars": 1987 }],
  "tables": [{ "sheet": "Sales", "headers": ["Region", "Amount"], "rows": [{ "Region": "North", "Amount": "100" }] }],
  "metadata": { "author": "...", "possiblyScanned": false }
}
```

Failed documents return `"success": false` with an `error` message.

### Pricing

Pay per page:

- **PDF:** each page
- **PowerPoint:** each slide
- **Excel:** each sheet
- **Word, HTML, TXT:** every 500 words (minimum 1)
- **CSV:** 1 page per file

Set a maximum cost per run in Apify and the tool stops cleanly before going over it.

### Limits

- Files up to 50 MB each.
- Scanned PDFs (images with no text layer) return little or no text. These are flagged with `metadata.possiblyScanned: true`. OCR isn't included yet.
- Old binary formats (.doc, .xls, .ppt) aren't supported. Save them as .docx, .xlsx or .pptx first.

### FAQ

**How do I convert a PDF to Markdown for ChatGPT, Claude or a RAG pipeline?** Paste the file link, keep *Split into chunks* on, and use the `markdown` or `chunks` fields.

**Can it convert Word (DOCX) to Markdown, or Excel (XLSX) to JSON?** Yes. Word becomes Markdown with headings, lists and tables; each Excel sheet becomes JSON rows and a Markdown table.

**How much does it cost?** About US$0.002 per page. A 50-page PDF costs about 10 cents.

### Use it from code or AI agents

Call it with the Apify API, the JavaScript or Python client, or through Apify's MCP server, so AI agents can convert documents on demand.

### Other Docsmith tools

- [Email Security Audit](https://apify.com/docsmith/email-security-audit): check SPF, DKIM, DMARC and SSL for many domains, with a grade and fixes.
- [Image Converter & Compressor](https://apify.com/docsmith/image-converter): convert and resize images to WebP, AVIF, JPG or PNG.
- [RSS Feed Reader & Monitor](https://apify.com/docsmith/rss-feed-reader): turn RSS, Atom and JSON feeds into JSON, with only-new-items alerts.
- [Bulk URL Status Checker](https://apify.com/docsmith/url-status-checker): find broken links, redirect chains and expiring SSL certificates.

# Actor input Schema

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

Direct links to the files you want to convert (PDF, DOCX, XLSX, PPTX, HTML, CSV, TXT or MD). Links must download the file itself, such as S3, Dropbox ?dl=1 or public storage links.

## `includeChunks` (type: `boolean`):

Add a chunks array with overlapping, heading-aware pieces, ready for embeddings and vector databases.

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

Target maximum characters per chunk.

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

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

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

For Excel and CSV files, add each sheet as JSON rows keyed by the header row.

## `includePlainText` (type: `boolean`):

Also add a text field with Markdown formatting removed.

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

Only convert the first N pages of each PDF (0 = all pages). Useful to cap cost.

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

Limit rows read from each spreadsheet sheet or CSV (0 = no limit).

## Actor input object example

```json
{
  "sources": [
    {
      "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
    }
  ],
  "includeChunks": true,
  "chunkSize": 2000,
  "chunkOverlap": 200,
  "includeTables": true,
  "includePlainText": false,
  "maxPagesPerDocument": 0,
  "maxRowsPerSheet": 1000
}
```

# Actor output Schema

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

All converted documents with Markdown, tables and chunks.

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

Summary table: URL, success, file type, title, pages, characters, 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 = {
    "sources": [
        {
            "url": "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("docsmith/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://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf" }] }

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

```

## MCP server setup

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