# Document to Markdown – DOCX, PPTX, XLSX, PDF for RAG & LLMs (`gazidev/document-to-markdown`) Actor

Convert Word, PowerPoint, Excel, PDF, HTML and CSV files to clean Markdown for RAG pipelines and LLMs. Give public URLs or upload files. Returns Markdown text, a saved .md file and basic metadata. No API key. From $2 per 1,000 documents.

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

## Pricing

from $2.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.

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 – DOCX, PPTX, XLSX, PDF for RAG & LLMs

Turn **Word, PowerPoint, Excel, PDF, HTML and CSV** files into clean **Markdown** for RAG pipelines, LLM prompts and knowledge bases. Give public links or upload files. For each document you get the Markdown text, a saved `.md` file and basic metadata.

No API key and no AI model: conversion runs inside the Actor. Files are converted with [MarkItDown](https://github.com/microsoft/markitdown) (Microsoft, MIT licence) and, for Excel, a streaming renderer built on [openpyxl](https://openpyxl.readthedocs.io/) (MIT).

### What you get per format

| Format | Output | Good to know |
|---|---|---|
| **DOCX** | Headings, lists, tables, links | Images keep their alt text only. Their pixels are not extracted |
| **PPTX** | One section per slide: title, text, tables, chart data as tables, speaker notes | Pictures keep their alt text only |
| **XLSX** | One `## Sheet` per visible sheet, one Markdown table per sheet | See "Excel details" below |
| **PDF** | Reading-order text, with simple tables where detected | Needs a text layer. Layout-heavy pages come out rough |
| **HTML** | Main structure as Markdown; scripts and styles removed | The saved HTML only: no JavaScript is run |
| **CSV** | A Markdown table. Comma, semicolon, tab and `\|` delimiters are detected; encoding too | |

The type is read from the file's content, not its link. A link ending in `.xlsx` that actually returns a login or error page gets a clear free error row instead of a page of junk.

### Input example

```json
{
  "urls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
    "https://raw.githubusercontent.com/microsoft/markitdown/v0.1.5/packages/markitdown/tests/test_files/test.xlsx"
  ],
  "maxFileMb": 25,
  "saveMdFile": true,
  "maxItems": 100
}
```

| Field | Default | Notes |
|---|---|---|
| `urls` | 3 samples in the form | Direct download links. `https://` is added if missing. Duplicates are skipped |
| `files` | none | File upload. Samples left untouched in `urls` are skipped when you upload |
| `maxFileMb` | 25 | Larger files get a free error row. Maximum 100 |
| `saveMdFile` | `true` | Saves a `.md` file and returns `mdFileUrl` |
| `maxItems` | 100 | Maximum documents per run |

### Output example

```json
{
  "status": "ok",
  "sourceUrl": "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
  "finalUrl": "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
  "fileName": "fw9.pdf",
  "fileType": "pdf",
  "sizeBytes": 140815,
  "title": "Form W-9 (Rev. March 2024)",
  "markdown": "Form  W-9\n\n(Rev. March 2024)\nDepartment of the Treasury ...",
  "charCount": 38059,
  "markdownTruncated": false,
  "mdFileUrl": "https://api.apify.com/v2/key-value-stores/<store-id>/records/00001-fw9.md",
  "warnings": [],
  "error": null,
  "convertedAt": "2026-11-05T13:47:39Z"
}
```

`status` is `ok`, `error`, `blocked` or `invalid`. Only `ok` rows are charged. `title` comes from the file's own metadata or, failing that, its first heading, so it can be missing or generic. A dataset row holds up to 2.5 MB of Markdown: longer results set `markdownTruncated: true` and the full text is in `mdFileUrl`. The key-value store record `OUTPUT` has a run summary.

### Pricing

Pay per event, and failed documents are free.

| Event | Price | When |
|---|---|---|
| `document-converted` | **$0.002** | Each converted document, including its first 10 MB and first 100,000 Markdown characters |
| `extra-10mb` | $0.002 | Each started 10 MB beyond the first 10 MB of the file |
| `extra-100k-chars` | $0.002 | Each started 100,000 Markdown characters beyond the first 100,000 |

So most documents cost $0.002 ($2 per 1,000). A 142-page tax guide (IRS Publication 17, 1.29 million characters) costs $0.026. A 100,000-row workbook of 10 million characters costs about $0.20. If a document would go past your run's maximum total charge, it is not delivered and not charged, and the run stops there.

### Limits

- **Scanned PDFs have no text to convert.** They get a free error row. Use [PDF OCR](https://apify.com/gazidev/pdf-ocr) for those.
- **Forms and complex layouts come out rough.** Rotated side text can appear one letter per line, as in IRS Form W-9, and multi-column pages or merged tables can lose their structure. For PDF-only work with page ranges and RAG chunks, see [PDF to Text & Markdown](https://apify.com/gazidev/pdf-text-extractor).
- **Images are not read.** There is no OCR and no image description.
- **Not supported:** legacy `.doc`, `.xls` and `.ppt`, password-protected files, `.xlsb`, EPUB and archives. Each gets a free error row saying so.
- **Direct links only.** Google Drive or Dropbox viewer pages and sign-in pages are not documents.
- **Memory and time.** Each conversion may take up to 180 s and the memory of the run (1 GB by default). Longer or heavier documents get a free error row; raise the run's memory for those.

#### Excel details

- Hidden sheets are skipped, and the row's `warnings` says how many.
- Formula cells show the value last saved in the file. A workbook produced by a script that never calculated it has empty formula cells.
- Merged cells show their value in the first cell only. Empty rows and outer empty columns are removed. The first non-empty row of a sheet is treated as the header.

### Safety and politeness

- **Private networks are blocked.** Before any connection, the host is resolved and every address must be public. Loopback, private ranges, link-local and cloud metadata addresses get a free `blocked` row. The check applies again to every redirect hop, and the socket connects to the address that was checked, so DNS tricks do not get around it.
- **robots.txt is respected.** A URL its site disallows for generic crawlers gets a free `blocked` row, and so does a site whose robots.txt answers with a server error. Requests to the same host are at least 1 s apart. There are no proxies or browser disguises. Sites that refuse datacenter IPs (some answer HTTP 403) give a free error row: upload those files instead.
- **Your files:** temporary copies are deleted after each document. Results stay in the run's storage under your account's retention settings.
- **Documents are data.** Text inside a document is passed through as it is, so treat it as untrusted input in your LLM prompts.

### Related Actors

- [PDF to Text & Markdown](https://apify.com/gazidev/pdf-text-extractor): PDF only, per page, with chunks and OCR.
- [PDF OCR](https://apify.com/gazidev/pdf-ocr): scanned PDFs.
- [Website to Markdown](https://apify.com/gazidev/website-to-markdown): whole websites and sitemaps.

# Actor input Schema

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

Direct links to DOCX, PPTX, XLSX, PDF, HTML or CSV files, one per line. The type is read from the file itself, not the link. Share pages (Google Drive, Dropbox viewers) are not direct links. Duplicates are skipped.

## `files` (type: `array`):

Upload documents from your computer. If you upload files and leave the sample URLs above untouched, the samples are skipped.

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

Larger files get a free error row and are not converted. Each started 10 MB above the first 10 MB is charged as `extra-10mb`.

## `saveMdFile` (type: `boolean`):

Also save each result as a .md file in the key-value store and return its link in `mdFileUrl`. Markdown over 2.5 MB is always saved, because a dataset row holds only the first 2.5 MB.

## `maxItems` (type: `integer`):

Stop after this many documents in one run.

## Actor input object example

```json
{
  "urls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
    "https://raw.githubusercontent.com/microsoft/markitdown/v0.1.5/packages/markitdown/tests/test_files/test.xlsx",
    "https://raw.githubusercontent.com/microsoft/markitdown/v0.1.5/packages/markitdown/tests/test_files/test.pptx"
  ],
  "maxFileMb": 25,
  "saveMdFile": true,
  "maxItems": 100
}
```

# Actor output Schema

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

No description

## `mdFiles` (type: `string`):

No description

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

No description

# 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://www.irs.gov/pub/irs-pdf/fw9.pdf",
        "https://raw.githubusercontent.com/microsoft/markitdown/v0.1.5/packages/markitdown/tests/test_files/test.xlsx",
        "https://raw.githubusercontent.com/microsoft/markitdown/v0.1.5/packages/markitdown/tests/test_files/test.pptx"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("gazidev/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://www.irs.gov/pub/irs-pdf/fw9.pdf",
        "https://raw.githubusercontent.com/microsoft/markitdown/v0.1.5/packages/markitdown/tests/test_files/test.xlsx",
        "https://raw.githubusercontent.com/microsoft/markitdown/v0.1.5/packages/markitdown/tests/test_files/test.pptx",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("gazidev/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://www.irs.gov/pub/irs-pdf/fw9.pdf",
    "https://raw.githubusercontent.com/microsoft/markitdown/v0.1.5/packages/markitdown/tests/test_files/test.xlsx",
    "https://raw.githubusercontent.com/microsoft/markitdown/v0.1.5/packages/markitdown/tests/test_files/test.pptx"
  ]
}' |
apify call gazidev/document-to-markdown --silent --output-dataset

```

## MCP server setup

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