# Document to Markdown & JSON API: PDF, DOCX, PPTX, HTML, OCR (`plainprobe/document-to-markdown`) Actor

Convert a PDF, Word, PowerPoint, HTML page or scanned image to clean Markdown for LLMs and RAG. Input: document URLs. Output: one JSON row per document with Markdown, tables as JSON, OCR text and ready-to-embed chunks with heading paths and page numbers.

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

## Pricing

from $2.80 / 1,000 documents converted

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/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 & JSON API: PDF, DOCX, PPTX, HTML, OCR

Turn public PDF, Word, PowerPoint, HTML and image files into clean Markdown and structured JSON that an LLM or a RAG pipeline can use directly: headings, paragraphs, tables as JSON records, correct reading order on two-column papers, built-in OCR for scanned pages, and optional ready-to-embed chunks with their heading path and page range.

Everything runs inside the Actor (no third-party conversion API, no AI model calls): your documents are not sent anywhere else.

![Real output: an arXiv PDF converted to Markdown, with a table returned as JSON](https://api.apify.com/v2/key-value-stores/DPjBqgP8luDMRsd1N/records/document-to-markdown-hero.png)

> **Switching from memo23/pdf-text-extractor or automation-lab/pdf-text-extractor?** Keep your input and your automation: `urls`, `urlsText`, `pageRange` starting at page 1, `firstNPages` and `maxPages` are understood, and each result also carries their field names (`text`, `charCount`, `fileName`; or `pdfUrl`, `fullText`, `textExtractionStatus`). Only the Actor ID changes in n8n, Make or your code.
>
> **Price:** **$4.00 per 1,000 documents** (up to 50 pages each) on the free plan (less on paid plans), no start fee; failures are free. memo23/pdf-text-extractor: $5.00 per 1,000 PDFs plus $0.005 per run; automation-lab/pdf-text-extractor: $3.00 per 1,000 PDFs plus $0.005 per run (public Store prices, 4 December 2026).
>
> **Launch offer:** your first 25 documents are free on every Apify account until 31 January 2027.

### For AI agents (MCP)

- Add it to any MCP client: `https://mcp.apify.com/?tools=plainprobe/document-to-markdown`
- Minimal input: `{"urls": [{"url": "https://arxiv.org/pdf/1706.03762"}]}`. Add `"chunking": true` to get RAG chunks.
- Key fields: `status` (`ok` / `failed`), `title`, `markdown`, `pages[].tables`, `chunks[].text`, `chunks[].headings`, `truncated`, `error.code`, `error.retryable`.
- Cost: $0.004 per converted document (first 50 pages included), $0.0001 per extra page, $0.002 per page read with OCR. Failed documents are free.
- Time: about 1 to 10 s per document (a 15-page paper: about 2 s). Measured batch: 20 PDFs, 502 pages, in 56 s.
- Limits: up to 1,000 URLs per run, 50 MB per file (configurable), 500 pages per document (configurable). Public URLs only.

### What does Document to Markdown do?

| Field | Type | Meaning |
|---|---|---|
| `url` | string | The URL you sent |
| `status` | `ok` | `failed` | `failed` results are never charged |
| `format` | string | Detected from the file content, not the extension: `pdf`, `docx`, `pptx`, `html`, `image` |
| `title` | string | null | From metadata, or the first large heading when metadata is empty or useless ("untitled", "Microsoft Word - …") |
| `pageCount`, `pagesConverted`, `truncated` | integer, integer, boolean | `truncated: true` when `maxPages` cut the document |
| `wordCount`, `ocrPages` | integer | Words in the Markdown; pages read with OCR |
| `markdown` | string | The whole document: `#`/`##`/`###` headings, paragraphs, lists, Markdown tables |
| `pages` | array | null | Per page: `page`, `markdown`, `tables` (records with `header` and `rows`), `ocr` (`confidence` 0-100, `words`, `error`) |
| `chunks` | array | null | When `chunking` is on: `index`, `text`, `word_count`, `headings` (path), `page_start`, `page_end` |
| `error` | object | null | `code`, `message`, `retryable` |
| `durationMs`, `convertedAt` | integer, ISO 8601 | Processing time and UTC timestamp |

What the converter handles for you:

- **Tables**: ruled tables and "booktabs" tables (horizontal rules only, as in most papers) become Markdown tables and JSON records, with multi-line headers merged.
- **Reading order**: two-column layouts are read column by column; full-width blocks stay in place.
- **Clean text**: words split by end-of-line hyphens are rejoined ("pre-trained" is kept when the compound form exists elsewhere), rotated margin stamps are removed, paragraphs are rebuilt from line spacing.
- **Headings**: by font size, plus numbered bold section titles ("2.1 Model Architecture").
- **OCR**: Tesseract 5, run automatically on pages with no text layer (`ocr: "auto"`), or on every page (`always`), or never (`off`). Languages: English, French, German, Spanish, Italian, Portuguese, Dutch (up to 4 at once).
- **HTML**: scripts, styles, forms and hidden elements dropped, links made absolute; `htmlMainContentOnly` also drops navigation, header, footer and sidebars.
- **Chunks**: split on paragraph boundaries; a paragraph that fits is never cut; each chunk carries its heading path and pages, so citations point to the right place.

**Runs on Apify:** call it from the API or an AI agent (MCP), schedule it, connect it to Make, Zapier or n8n, and export results as JSON, CSV or Excel.

### How to use Document to Markdown (start in 30 seconds)

1. Click **Try for free**.
2. Keep the default input (the "Attention Is All You Need" paper on arXiv) or paste the URLs of your own public PDF, DOCX, PPTX, HTML or image files.
3. Click **Start**. The Markdown and the tables appear in the **Output** tab; export them as JSON, CSV or Excel, or copy the `markdown` field straight into your LLM prompt.
4. Building a RAG index? Turn on **chunking** to get ready-to-embed pieces with their heading path and page range.

### Use it from your code, an AI agent or a no-code tool

- **API**: `POST https://api.apify.com/v2/acts/plainprobe~document-to-markdown/run-sync-get-dataset-items?token=<YOUR_TOKEN>` with `{"urls": [{"url": "https://arxiv.org/pdf/1706.03762"}]}` as JSON body; the converted documents come back in the response.
- **AI agents (MCP)**: add the Apify MCP server (`https://mcp.apify.com`) to Claude, Cursor or any MCP client; the Actor is callable as a tool (details in the section above).
- **No-code and RAG pipelines**: n8n, Make and Zapier have official Apify integrations (Run Actor, then Get dataset items); LangChain and LlamaIndex have Apify loaders that read the dataset directly.

### When to use it, and when not

Use it to feed papers, reports, manuals, slide decks, contracts or web pages to an LLM, to build a RAG index, or to extract the tables of a public PDF as JSON.

Do not use it for: files behind a login (only public URLs are fetched), handwriting, complex formulas (they come out as plain text), or pixel-perfect layout reproduction. Charts are not described in words; chart-heavy pages are read for their text only. Password-protected PDFs return `ENCRYPTED_PDF`.

### Input and output example

Input (the one used in the benchmark, per-page output off):

```json
{"urls": [{"url": "https://arxiv.org/pdf/1706.03762"}], "includePages": false}
```

Output (real run iUFbeVWEdTYjKqCTR, build 0.1.6; `markdown` shortened):

```json
{
  "url": "https://arxiv.org/pdf/1706.03762",
  "status": "ok",
  "format": "pdf",
  "title": "Attention Is All You Need",
  "pageCount": 15,
  "pagesConverted": 15,
  "truncated": false,
  "wordCount": 6383,
  "ocrPages": 0,
  "markdown": "Provided proper attribution is provided, Google hereby grants permission to\nreproduce the tables and figures in this paper solely for use in journalis…",
  "pages": null,
  "chunks": null,
  "error": null,
  "durationMs": 2126,
  "convertedAt": "2026-12-01T09:47:45Z"
}
```

With `includePages` (default on), each `pages[]` item is `{"page", "markdown", "tables": [{"header": [...], "rows": [{"<header>": "<cell>", ...}]}], "ocr"}`. With `chunking: true`, each `chunks[]` item is `{"index", "text", "word_count", "headings": [...], "page_start", "page_end"}`.

### Input

| Field | Default | What it does |
|---|---|---|
| `urls` | required | Public URLs of PDF, DOCX, PPTX, HTML or image files (PNG, JPEG, TIFF, WebP), up to 1,000 per run. |
| `ocr`, `ocrLanguages` | `auto`, `["eng"]` | `auto` runs OCR only on scanned pages without a text layer; up to 4 languages. |
| `maxPages` | 500 | Longer documents are cut and marked `truncated: true` (max 500). |
| `maxFileSizeMb` | 50 | Larger files return `FILE_TOO_LARGE`, not billed (max 100). |
| `chunking`, `chunkMaxWords`, `chunkOverlapWords` | off, 300, 40 | RAG chunks split on paragraph boundaries, with heading path and page range. |
| `includePages` | `true` | Per-page Markdown, tables as JSON and OCR confidence. |
| `htmlMainContentOnly` | off | Drop navigation, header, footer and sidebars from HTML pages. |

### Limits

- 1,000 files per run, 500 pages and 100 MB per file at most; one bad file never stops the batch.
- Runs use 8 GB of memory by default (2 CPUs, pages converted in parallel); see the FAQ to lower it.
- Only public http(s) URLs; private and internal addresses are refused. No password-protected files.

### Errors

Errors are per document: one bad URL never stops the batch. Failed documents are not charged.

| Code | Meaning | What to do |
|---|---|---|
| `INVALID_URL` | Not an http(s) URL | Fix the URL |
| `UNSAFE_URL` | Points to a private or internal address | Use a public URL |
| `DOWNLOAD_FAILED` | The server answered with an error (`retryable` tells you if a retry may help) | Check the URL in a browser |
| `FILE_TOO_LARGE` | Bigger than `maxFileSizeMb` | Raise the limit (memory permitting) |
| `TIMEOUT` | Download or conversion took too long | Retry; split very large files |
| `UNSUPPORTED_FORMAT` | Not a PDF, DOCX, PPTX, HTML or image file | Convert the file first |
| `INVALID_DOCUMENT` / `INVALID_PDF` | Damaged or unreadable file | — |
| `ENCRYPTED_PDF` | Password-protected PDF | Not supported |
| `INVALID_LANGUAGE` | OCR language not in the list | Use eng, fra, deu, spa, ita, por, nld |
| `OCR_TIMEOUT` / `OCR_FAILED` | One page could not be read by OCR | The rest of the document is still returned |

### Benchmarks

Measured on 2026-12-01 with the same 20 public PDFs (502 pages: research papers, government forms, manuals). Raw data and script: `benchmarks/`.

| | Plainprobe Document to Markdown | memo23/pdf-text-extractor |
|---|---|---|
| Documents converted | 20/20 | 20/20 |
| Tables returned as Markdown / JSON | **118** | 0 |
| Text recovered on two-column papers (LLaMA-2) | **47.4k words** | 42.6k words |
| Words extracted | within ±5 % | within ±5 % |
| Run time for 20 PDFs | 56 s (8 GB) | **14 s** |
| Price for these 20 PDFs | **$0.08** + start fee | $0.105 |

memo23 is faster because it extracts plain text only, without table detection or layout analysis. If you only need raw text and speed matters more than structure, it is a good choice.

### How much does it cost to convert documents to Markdown?

**Launch offer:** the first 25 documents of each Apify account are free until 31 January 2027 (the count is kept in a small key-value store named `document-to-markdown-launch-offer` in your own account; if the Actor cannot open it, the normal price applies).

**Free to try:** the Apify free plan includes $5 of platform credit every month, enough for about **1,000 text documents** (in batches) with this Actor.

Pay per event:

- **$0.004 per document converted** (status `ok`), first 50 pages included;
- $0.0001 per page beyond 50;
- $0.002 per page read with OCR (scanned pages and images only);
- plus Apify's start fee ($0.00005 per GB of memory, so $0.0004 at the default 8 GB).

Failed documents are free. A 30-page text PDF costs $0.004; a 200-page manual $0.019; a 10-page scan $0.024.

### Privacy and licences

Files are downloaded, converted in memory and not kept after the run, except the results in your own dataset. Author names from document metadata are never returned. Make sure you have the right to process the documents you send. Built with pdfplumber (MIT), pypdfium2 (Apache-2.0/BSD), python-docx (MIT), python-pptx (MIT) and Tesseract (Apache-2.0).

### FAQ, disclaimers and support

**Does it use an AI model?** No. Conversion is deterministic: the same file gives the same output, and nothing is sent to an LLM provider.

**Why 8 GB of memory by default?** Pages are converted in parallel processes and Apify gives 1 CPU per 4 GB. At 8 GB our 20-PDF batch took 56 s instead of 119 s at 4 GB, for about 17 % more compute. At 1 GB (a quarter of a CPU) a 15-page paper took 55 s instead of 5 s. Lower it if you convert a few small files and are not in a hurry.

**Can I send local files?** Upload them to any public storage (for example an Apify key-value store record with a public URL) and pass that URL.

**Is this affiliated with arXiv, Microsoft or Tesseract?** No. Plainprobe is independent.

**Disclaimer.** Conversion is automatic and deterministic; check key figures and tables against the original document before any legal or financial use. Plainprobe is independent and not affiliated with the publishers of the files you convert.

**Support.** Found a wrong result or need a field? Open an issue in the **Issues** tab: we read issues every day.

### Switching from another Actor

Send the input you already use with memo23/pdf-text-extractor or automation-lab/pdf-text-extractor: `urls`, `urlsText`, `pageRange` starting at page 1, `firstNPages` and `maxPages` are understood, and each result also carries their field names (`text`, `charCount`, `fileName`; or `pdfUrl`, `fullText`, `textExtractionStatus`). The field `outputFormat` (default `auto`) picks the compatible output from the field names you send; set it to `plainprobe` to get only our own fields.

Public reliability of those Actors (Apify API `publicActorRunStats30Days`, 4 December 2026, runs that failed, timed out or were aborted): memo23/pdf-text-extractor 0.1 % of 21,405 runs, automation-lab/pdf-text-extractor 0.6 % of 1,465 runs.

### Like it?

If this Actor saves you time, a short rating on its **Reviews** tab helps other users find it. Something missing or wrong? Open an issue on the **Issues** tab: it is answered and fixed quickly.

### More from Plainprobe

Step-by-step guides: [PDF to Markdown for LLMs](https://plainprobe.github.io/guides/pdf-to-markdown-for-llm/), [convert DOCX to Markdown](https://plainprobe.github.io/guides/convert-docx-to-markdown/), [convert HTML to Markdown](https://plainprobe.github.io/guides/convert-html-to-markdown/).

Other Plainprobe tools (company records from official registers, website screenshots and visual monitoring, SEO and AI readiness audits) and how to call them from an AI agent: [plainprobe.github.io](https://plainprobe.github.io/).

# Actor input Schema

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

Public URLs of PDF, DOCX, PPTX, HTML or image files (PNG, JPEG, TIFF, WebP), up to 1,000 per run. The type is detected from the file content, not the extension. Plain strings or {"url": ...} objects are both accepted.

## `ocr` (type: `string`):

auto runs OCR only on scanned pages without a text layer.

## `ocrLanguages` (type: `array`):

Up to 4 languages of the scanned text.

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

Longer documents are cut and marked truncated: true.

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

Files larger than this are refused with FILE_TOO_LARGE (not billed).

## `chunking` (type: `boolean`):

Adds chunks split on paragraph boundaries, each with its heading path and page range.

## `chunkMaxWords` (type: `integer`):

Maximum words per chunk; paragraphs that fit are never cut.

## `chunkOverlapWords` (type: `integer`):

Words repeated at the start of the next chunk (at most half the chunk size).

## `includePages` (type: `boolean`):

Per-page Markdown, tables as JSON and OCR confidence.

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

Drop navigation, header, footer and sidebars from HTML pages.

## `outputFormat` (type: `string`):

Switching from another PDF text Actor? Send your existing input unchanged (urls, urlsText, pageRange starting at page 1, firstNPages, maxPages are understood) and each result also carries that Actor's field names (text, charCount, fileName; or pdfUrl, fullText, textExtractionStatus). Our own fields are always kept.

## Actor input object example

```json
{
  "urls": [
    "https://arxiv.org/pdf/1706.03762"
  ],
  "ocr": "auto",
  "ocrLanguages": [
    "eng"
  ],
  "maxPages": 500,
  "maxFileSizeMb": 50,
  "chunking": false,
  "chunkMaxWords": 300,
  "chunkOverlapWords": 40,
  "includePages": true,
  "htmlMainContentOnly": false,
  "outputFormat": "auto"
}
```

# Actor output Schema

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

One item per URL: status, format, title, page and word counts, OCR pages, typed error if any.

## `markdown` (type: `string`):

Full Markdown of each document.

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

Complete records with per-page tables and RAG chunks.

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

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

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

```

## MCP server setup

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