# Document to Markdown for AI – PDF, Word, Excel, PPT, HTML (`goldfoot/document-to-markdown`) Actor

Convert PDFs, Word, Excel, PowerPoint, EPUB, Outlook and web pages into clean Markdown for LLMs and RAG. Tables preserved, main-content extraction for web pages, built-in chunking with token counts.

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

## Pricing

$4.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, Excel, PowerPoint, HTML → Markdown

Convert **any document or web page into clean, LLM-ready Markdown**: PDFs, Word, Excel, PowerPoint, EPUB, Outlook emails, CSV/JSON/XML and HTML pages. Headings, lists and **tables are preserved**. Web pages are reduced to their **main content** (no menus, footers or cookie notices). Optional **heading-aware chunking with token counts** for RAG and vector databases.

✅ PDF, DOCX, XLSX/XLS, PPTX, EPUB, MSG, CSV, JSON, XML, HTML · ✅ Tables kept as Markdown tables · ✅ Main-content extraction for web pages · ✅ RAG chunking with overlap · ✅ Token estimates · ✅ Bulk & parallel · ✅ Failed documents are free

### Use cases

- **RAG pipelines & vector databases** — feed Pinecone, Qdrant, Weaviate, pgvector or OpenAI/Claude file search with clean, chunked Markdown.
- **AI agents** — let an agent read any PDF or Office file from a URL in one call.
- **Knowledge bases** — turn manuals, reports, contracts and spreadsheets into searchable text.
- **Content migration** — move Word/HTML content into Markdown-based CMSs, docs sites or Notion.
- **Data extraction** — get tables out of PDFs and spreadsheets as Markdown.

### How to use

1. Paste URLs of documents or web pages (one per line).
2. Optional: set **Chunk size** (e.g. 500 tokens) for RAG.
3. Click **Start**. Each dataset item contains `markdown`, `title`, `approxTokens` and optional `chunks`.

### Input example

```json
{
  "sources": [
    "https://arxiv.org/pdf/1706.03762",
    "https://example.com/annual-report.docx",
    "https://en.wikipedia.org/wiki/Markdown"
  ],
  "chunkSizeTokens": 500,
  "chunkOverlapTokens": 50
}
```

### Output example

```json
{
  "url": "https://arxiv.org/pdf/1706.03762",
  "finalUrl": "https://arxiv.org/pdf/1706.03762",
  "success": true,
  "fileType": "pdf",
  "contentType": "application/pdf",
  "bytes": 2215244,
  "title": null,
  "chars": 39512,
  "approxTokens": 9878,
  "markdown": "Attention Is All You Need\n\n...",
  "chunks": [
    { "index": 0, "headingPath": null, "text": "Attention Is All You Need ...", "approxTokens": 498 }
  ]
}
```

### Pricing

You pay **per successfully converted document** (see the Pricing tab). Documents that can't be downloaded or contain no extractable text are **free**.

### Limits & tips

- Files up to 100 MB. Very large results (>4M characters) are truncated in the dataset item but saved in full as a `.md` file (`markdownFileUrl`).
- Scanned/image-only PDFs contain no text layer and return an error (free). OCR is on the roadmap. Tell us in Issues if you need it.
- Only public URLs are supported (no login-protected files).
- Token counts are estimates (≈ 4 characters per token).

### Support

Open an issue on the **Issues** tab with an example URL. We usually respond within a few days.

# Actor input Schema

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

Public URLs of PDFs, Word (.docx), Excel (.xlsx/.xls), PowerPoint (.pptx), EPUB, Outlook (.msg), CSV/JSON/XML files or web pages. One per line.

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

Strip navigation, footers, cookie notices and sidebars from web pages and keep only the article/main content.

## `keepLinks` (type: `boolean`):

Keep hyperlinks as Markdown links. Off gives cleaner text for LLMs.

## `chunkSizeTokens` (type: `integer`):

Split the Markdown into heading-aware chunks of about this many tokens for RAG / vector databases. 0 = no chunking.

## `chunkOverlapTokens` (type: `integer`):

Repeat this many tokens from the previous chunk at the start of each chunk.

## `saveMarkdownFiles` (type: `boolean`):

Store each result as a .md file in the key-value store and return a download link.

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

How many documents to process in parallel.

## Actor input object example

```json
{
  "sources": [
    "https://arxiv.org/pdf/1706.03762",
    "https://en.wikipedia.org/wiki/Markdown"
  ],
  "htmlMainContentOnly": true,
  "keepLinks": false,
  "chunkSizeTokens": 0,
  "chunkOverlapTokens": 0,
  "saveMarkdownFiles": false,
  "maxConcurrency": 4
}
```

# Actor output Schema

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

Converted documents with markdown, title, token counts and optional chunks.

## `files` (type: `string`):

Saved .md files (when enabled or for very large documents).

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

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

```

## MCP server setup

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