# Document to Markdown for LLMs (PDF, Word, PowerPoint, Excel) (`squarish_altruism/doc-to-markdown`) Actor

Convert PDF, DOCX, PPTX, XLSX, HTML, CSV, EPUB and more from URLs into clean Markdown for AI, RAG and LLM pipelines. Keeps headings, lists and tables; optional ready-made chunks. Pay per document.

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

## Pricing

Pay per event

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 LLMs (PDF, Word, PowerPoint, Excel)

> **At a glance:** convert documents from URLs into clean Markdown for AI tools. **You get** one row per document with its text. **Cost:** 1,000 typical documents are about $2.

Convert documents from URLs into **clean Markdown**, ready for ChatGPT, Claude, RAG pipelines, vector databases and AI agents. One Actor handles **PDF, Word (DOCX), PowerPoint (PPTX), Excel (XLSX/XLS), HTML pages, CSV, JSON, XML, TXT, Markdown, EPUB and Jupyter notebooks**.

What it keeps:

- headings, lists, bold and italic text, links and tables
- tables in Excel files and ruled tables in PDFs, as Markdown tables

It can also split every document into **ready-made chunks** for embeddings.

You don't need an API key or any setup. Paste links and run.

### Why use it

- **Many formats in one place:** mix PDFs, slide decks and spreadsheets in a single run, so you don't need a separate tool for each format.
- **Text that reads properly:** PDF text keeps its word spacing even in tightly typeset papers, so you don't get "wordsruntogether". Rotated figure labels and chart text are removed, and ruled tables become real Markdown tables.
- **Ready for RAG:** optional chunking splits at headings and paragraphs, never mid-sentence where it can avoid it, with configurable overlap.
- **Fair, simple pricing:** pay per document. Long documents pay a small amount per extra page, and failed downloads and unsupported files are free.
- **Fast and inexpensive:** no browser or OCR engine, so a typical document converts in under a second.

### Input

| Field | Default | Description |
|---|---|---|
| `sources` | — | Document URLs. Paste many, or upload a list. |
| `includeMarkdown` | `true` | Put the Markdown in each dataset row. |
| `saveMarkdownFiles` | `false` | Also save a `.md` file per document, with a download link. |
| `chunkSize` | `0` | Split into chunks of at most N characters (`0` = off). 1,000–4,000 is typical for embeddings. |
| `chunkOverlap` | `0` | Characters repeated between consecutive chunks. |
| `maxFileSizeMb` | `50` | Larger files are skipped and not charged. |
| `maxConcurrency` | `4` | Documents processed in parallel. |

```json
{
  "sources": [
    { "url": "https://arxiv.org/pdf/1706.03762" },
    { "url": "https://example.com/quarterly-report.docx" },
    { "url": "https://example.com/pricing.xlsx" }
  ],
  "chunkSize": 2000,
  "chunkOverlap": 150
}
```

### Output

One row per document:

```json
{
  "index": 0,
  "url": "https://arxiv.org/pdf/1706.03762",
  "fileType": "pdf",
  "pages": 15,
  "billedExtraPages": 5,
  "title": null,
  "characters": 39871,
  "words": 5912,
  "markdown": "Attention Is All You Need\n\nAshish Vaswani …\n\nAbstract\n\nThe dominant sequence transduction models …",
  "chunks": ["Attention Is All You Need …", "…"],
  "markdownUrl": "https://api.apify.com/v2/key-value-stores/…/records/0001-1706-03762-ab12cd34.md"
}
```

- If a document can't be processed, its row has an `error` field, and you aren't charged for it.
- If a PDF has no text layer (a scanned PDF), its row has a `warning` field.

### Pricing

- **$0.002 per document**, including up to 10 pages.
- **$0.0002 per extra page** after that.

| Example | Cost |
|---|---|
| A 15-page paper | $0.003 |
| 1,000 typical documents | about $2 |

"Pages" means:

- the real page count for PDFs
- slides for PowerPoint
- sheets for Excel
- about 500 words per page for other formats

### Use cases

- **RAG and chatbots:** ingest PDFs, manuals, policies and slide decks into a vector database.
- **AI agents:** give an agent a tool that reads any document link as Markdown.
- **Research:** turn papers and reports into text you can search, summarise and compare.
- **Data extraction:** turn spreadsheets and tables into Markdown for LLM prompts.
- **Content migration:** convert Word documents into Markdown for docs sites and wikis.

### Use with AI agents (MCP)

This Actor works as a tool for AI assistants such as Claude, ChatGPT and Cursor, through [Apify's MCP server](https://mcp.apify.com).

1. Add the server to your MCP client, with this Actor selected:

```json
{
  "mcpServers": {
    "apify": { "url": "https://mcp.apify.com?tools=squarish_altruism/doc-to-markdown" }
  }
}
```

In Claude Code: `claude mcp add apify "https://mcp.apify.com?tools=squarish_altruism/doc-to-markdown" -t http`

2. Sign in with your Apify account when your client asks. If it can't use OAuth, send your Apify API token in an `Authorization: Bearer` header.
3. Ask in plain language, for example: *"Convert https://arxiv.org/pdf/1706.03762 to Markdown and summarise section 3."*

Runs started by an agent are billed to your Apify account at the same prices as above.

### Limitations

- **No OCR:** scanned PDFs (images of pages) produce little or no text and get a warning.
- **Legacy formats:** `.doc` and `.ppt` aren't supported. Save them as `.docx` or `.pptx`.
- **Complex PDF tables:** tables without ruling lines, such as most academic tables, come out as neatly aligned text rows instead of Markdown tables.
- **Your own documents only:** convert documents you have the right to process.

Built on Microsoft's open-source [MarkItDown](https://github.com/microsoft/markitdown) (MIT licence) and [pdfplumber](https://github.com/jsvine/pdfplumber) (MIT licence), with improved PDF handling.

### Feedback

Need OCR, another format or a different chunking strategy? Open an issue on the **Issues** tab.

### Related tools

- [OCR for Images & Scanned PDFs](https://apify.com/squarish_altruism/ocr)
- [Audio & Video Transcription](https://apify.com/squarish_altruism/transcribe)
- [Website Screenshot & URL to PDF](https://apify.com/squarish_altruism/screenshot)

# Actor input Schema

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

Direct links to documents: PDF, DOCX, PPTX, XLSX, XLS, HTML, CSV, JSON, XML, TXT, MD, EPUB or IPYNB. Paste many links or upload a list.

## `includeMarkdown` (type: `boolean`):

Put the converted Markdown in each dataset row.

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

Save each document as a .md file in the key-value store and add a download link to its row. Very long documents are always saved as files.

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

Also split each document into chunks of at most this many characters for embeddings and RAG, breaking at headings and paragraphs. 0 = no chunks.

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

Characters repeated from the end of one chunk at the start of the next (max half the chunk size).

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

Larger files are skipped (not charged).

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

Documents processed in parallel.

## Actor input object example

```json
{
  "sources": [
    {
      "url": "https://arxiv.org/pdf/1706.03762"
    }
  ],
  "includeMarkdown": true,
  "saveMarkdownFiles": false,
  "chunkSize": 0,
  "chunkOverlap": 0,
  "maxFileSizeMb": 50,
  "maxConcurrency": 4
}
```

# Actor output Schema

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

One item per document, or per chunk when chunking is on.

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

Files saved to the run's default key-value store.

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

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

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

```

## MCP server setup

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