# Convert PDF, Word & Web Pages to Markdown + RAG Chunks (`tidybytetools/doc-to-markdown`) Actor

Convert PDF, Word (.docx) and web pages into clean Markdown, with optional RAG chunks. Offline for files. Price per page or document (see events). Failed files free. Works from Apify MCP and the API.

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

## Pricing

from $3.00 / 1,000 file 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

## PDF, Word & Web Page to Markdown + RAG Chunks

Give it links to PDF files, Word (.docx) files or web pages. It turns each one into clean Markdown, ready for ChatGPT, Claude, a vector database or your notes. It can also cut each file into chunks for AI search (RAG), with the heading and page number saved on every chunk.

- Keeps headings (`#`, `##`, `###`). In PDFs it finds them by font size and bold text
- Tables come out as real Markdown tables, not a jumble of words
- Joins paragraphs back together and fixes words split by a hyphen at the end of a line
- Keeps bullet and numbered lists, bold, italic and links (Word and web pages)
- Drops web page junk: menus, side bars, footers, scripts
- Reads scanned (picture-only) PDF pages with OCR, built in
- A bad link doesn't stop the run. You get an item with an `error` field and it moves on

### Website and local versions

- **[Website](https://tidybytetools.github.io/tools/doc2md/)** — Tidy Byte Tools product page
- **[Free local CLI + MCP](https://github.com/tidybytetools/doc2md-lite)** — `pip install doc2md-lite` (runs on your computer)
- **[Offline Pro on Gumroad](https://tidybyte.gumroad.com/l/frlkv)** — one-time download, no per-run fee

### Pricing

| Event | Price | When |
|---|---|---|
| File converted | **$0.003** | One PDF, Word file or web page turned into Markdown. A PDF's first 20 pages are included |
| Extra PDF page | **$0.0003** | Each PDF page after the first 20 |
| Scanned page read with OCR | **$0.005** | One picture-only PDF page we read with OCR and got text from |

Apify also adds its small standard start fee per run. Chunks are free.

You don't pay for:

- links that fail, or aren't a PDF, Word file or web page
- files where we found no text
- scanned pages when OCR is off

You're charged only after a file's results are saved. Set a maximum cost per run and the Actor stops before your limit and tells you in the dataset.

| What you run | Cost |
|---|---|
| 1 web page | $0.003 |
| 100 Word files | $0.30 |
| A 100-page PDF | $0.003 + 80 x $0.0003 = $0.027 |
| 1,000 PDFs of 10 pages each | $3.00 |
| A 10-page scanned PDF | $0.003 + 10 x $0.005 = $0.053 |

### Input

| Field | What it means |
|---|---|
| File links | Links to PDF files, Word .docx files or web pages |
| Make chunks for AI search | On by default. Each chunk keeps its heading path and pages |
| Dataset layout | One item per file, or one item per chunk (best for vector databases) |
| Chunk size / overlap | Default 1,500 and 200 characters (about 375 and 50 tokens) |
| PDF pages | Like `1,3-5`. Leave empty for all pages |
| Tables in PDFs | Tables with border lines (default), also tables lined up by spacing, or off |
| Scanned PDF pages (OCR) | On by default |
| Keep web page menus and footers | Off by default |
| Max pages per PDF | Default 300 |

Example input:

```json
{
  "fileUrls": [
    { "url": "https://example.com/handbook.pdf" },
    { "url": "https://example.com/policy.docx" },
    { "url": "https://example.com/help/returns" }
  ],
  "chunks": true,
  "outputMode": "documents",
  "chunkSize": 1500,
  "chunkOverlap": 200
}
```

### Output

With "One item per file" you get one dataset item per file:

```json
{
  "sourceUrl": "https://example.com/store-report.pdf",
  "fileName": "store-report.pdf",
  "type": "pdf",
  "title": "Spring Store Report",
  "pageCount": 2,
  "pagesRead": 2,
  "ocrPages": [],
  "tables": 1,
  "headings": 4,
  "characters": 608,
  "markdownFile": "doc-1.md",
  "markdown": "# Spring Store Report\n\n...",
  "chunkCount": 2,
  "chunks": [
    {
      "id": "store-report.pdf#1",
      "chunk": 1, "of": 2,
      "page": 1, "page_start": 1, "page_end": 1,
      "heading_path": ["Spring Store Report", "Sales"],
      "chars": 412, "approx_tokens": 103,
      "text": "..."
    }
  ],
  "charged": { "document-converted": 1 }
}
```

The full Markdown of each file is also saved in the run's key-value store as `doc-1.md`, `doc-2.md` and so on. Very long files (over 1 million characters) are cut short inside the dataset item (`markdownCut: true`), but the `.md` file is always complete.

With "One item per chunk" each chunk is its own dataset item, with `title` and `type` added. Export it as JSON or CSV and load it straight into a vector database.

A link that fails gives an item like this, and the run carries on:

```json
{ "sourceUrl": "https://example.com/missing.pdf", "error": "Client error '404 Not Found' for url 'https://example.com/missing.pdf'" }
```

### For AI agents

- **Use when:** you have public links to PDF, .docx or HTML files and need clean Markdown or RAG chunks with page and heading info.
- **Don't use when:** the file is behind a login, has a password, or is a format other than PDF, .docx or HTML (no .doc, .pptx, .xlsx).
- **Input:** `fileUrls` (list of `{"url": "..."}`), optional `chunks` (true/false), `outputMode` (`documents`, `chunks`), `chunkSize`, `chunkOverlap`, `pages` like `1,3-5`, `tables` (`lines`, `text`, `off`), `ocr` (`auto`, `never`), `keepPageMenus`, `maxPagesPerPdf`.
- **Output:** one item per file with `markdown`, `title`, `type`, `chunks`, `markdownFile`; or one item per chunk. A failed link gives `{sourceUrl, error}`.
- **Cost:** $0.003 per file (20 PDF pages included), $0.0003 per extra PDF page, $0.005 per OCR page. Failed files are free. The run never goes over your max cost.

### Run it on a schedule

If a help center, policy page or report changes often, create a **Task** with your links, then open **Schedules** in Apify Console and run it daily or weekly. Connect the run to Make, Zapier, n8n, a webhook or the API to send fresh Markdown and chunks to your AI app or vector database.

### FAQ

**How good is OCR?**
It reads clear scans well. Blurry or handwritten pages can come out with mistakes, so check them. OCR text comes out as plain paragraphs (no headings or tables). The item lists the pages read with OCR in `ocrPages`.

**Can it crawl a whole website?**
No. It converts the links you give it. Give it a list of page links (for example from a sitemap).

**Does it work with JavaScript-heavy pages?**
It reads the HTML the server sends. Pages that only show text after JavaScript runs may come out empty. Those are free.

**Can it open password-protected PDFs or old .doc files?**
No. Save .doc files as .docx first. The offline version below opens password-protected PDFs.

**Do you keep my files?**
Files are downloaded into the run and processed. Only your results stay in your own Apify storage, under your storage retention settings.

### Prefer to run it on your own computer?

The same converter is available as a Python tool you run offline, with no per-file cost: **[doc2md on Gumroad](https://tidybyte.gumroad.com/l/frlkv)**. There's also a free version, `doc2md-lite` (`pip install doc2md-lite`, [GitHub](https://github.com/tidybytetools/doc2md-lite)), with a free MCP server for AI apps.

### More tools from Tidy Byte Tools

These Actors work well together:

- [PDF Table Extractor](https://apify.com/tidybytetools/pdf-table-pull) — PDF tables to CSV, Excel and JSON. $0.003 per page with a table.
- [PDF, Word and Web Page to Markdown](https://apify.com/tidybytetools/doc-to-markdown) — Clean Markdown and RAG chunks. $0.003 per file.
- [HTML Table Extractor](https://apify.com/tidybytetools/html-table-extractor) — Web tables to CSV and JSON. $0.0005 per data row.
- [Broken Link Checker](https://apify.com/tidybytetools/broken-link-checker) — Check site and sitemap links. $0.001 per link.
- [Markdown Chunker for RAG](https://apify.com/tidybytetools/markdown-rag-chunker) — Split Markdown by headings. $0.0001 per chunk.
- [CSV and Excel Data Cleaner](https://apify.com/tidybytetools/csv-excel-data-cleaner) — Dedupe and fix dates, emails and phones. $0.0005 per clean row.
- [JSON to CSV Converter](https://apify.com/tidybytetools/json-to-csv-flattener) — Flatten nested JSON for spreadsheets. $0.0001 per row.
- [CSV Encoding Fixer and Splitter](https://apify.com/tidybytetools/csv-encoding-fixer-splitter) — Fix garbled letters like Ã© and split big files. $0.01 per file.
- [Phone Number Validator](https://apify.com/tidybytetools/phone-number-validator-formatter) — Check and format numbers offline. $0.001 per number.
- [LLM Token Counter](https://apify.com/tidybytetools/llm-token-counter) — Offline token and cost estimates for GPT, Claude and Gemini. $0.0005 per unique text.

Free local tools (no Apify account needed): [pdf-table-pull-lite](https://github.com/tidybytetools/pdf-table-pull-lite), [doc2md-lite](https://github.com/tidybytetools/doc2md-lite), [link-check-lite](https://github.com/tidybytetools/link-check-lite), [md-chunk-lite](https://github.com/tidybytetools/md-chunk-lite), [json-shaper-lite](https://github.com/tidybytetools/json-shaper-lite).

Website: <https://tidybytetools.github.io>. All Actors: [apify.com/tidybytetools](https://apify.com/tidybytetools).

### Agent tip

Convert PDF, Word (.docx) and web pages into clean Markdown, with optional RAG chunks. Offline for files. Price per page or document (see events). Failed files free. Works from Apify MCP and the API.

# Actor input Schema

## `fileUrls` (type: `array`):

Links to PDF files, Word (.docx) files or web pages. A PDF or Word link must download the file itself.

## `chunks` (type: `boolean`):

Also cut each file into chunks. Each chunk keeps its heading path and page numbers. Chunks are free.

## `outputMode` (type: `string`):

How results are laid out in the dataset. The full Markdown file is always saved in the key-value store too.

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

About how long each chunk is. 1,500 characters is about 375 tokens.

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

How much text the next chunk repeats from the one before, so ideas aren't cut in half.

## `pages` (type: `string`):

Which PDF pages to read, like 1,3-5. Leave empty for all pages.

## `tables` (type: `string`):

Tables become real Markdown tables. Word and web page tables are always kept.

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

Pages that are only a picture are read with OCR. Each one costs $0.005.

## `keepPageMenus` (type: `boolean`):

Off: we drop menus, side bars and footers from web pages, so you get just the main text.

## `maxPagesPerPdf` (type: `integer`):

We read at most this many pages from each PDF. Keeps costs in check on very long files.

## Actor input object example

```json
{
  "fileUrls": [
    {
      "url": "https://www.w3.org/WAI/WCAG21/working-examples/pdf-table/table.pdf"
    }
  ],
  "chunks": true,
  "outputMode": "documents",
  "chunkSize": 1500,
  "chunkOverlap": 200,
  "tables": "lines",
  "ocr": "auto",
  "keepPageMenus": false,
  "maxPagesPerPdf": 300
}
```

# Actor output Schema

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

No description

## `files` (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 = {
    "fileUrls": [
        {
            "url": "https://www.w3.org/WAI/WCAG21/working-examples/pdf-table/table.pdf"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("tidybytetools/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 = { "fileUrls": [{ "url": "https://www.w3.org/WAI/WCAG21/working-examples/pdf-table/table.pdf" }] }

# Run the Actor and wait for it to finish
run = client.actor("tidybytetools/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 '{
  "fileUrls": [
    {
      "url": "https://www.w3.org/WAI/WCAG21/working-examples/pdf-table/table.pdf"
    }
  ]
}' |
apify call tidybytetools/doc-to-markdown --silent --output-dataset

```

## MCP server setup

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