# DOCX to Markdown: Word to Text, Tables, Headings (`ucchiii/docx-to-markdown`) Actor

Convert Word .docx files from URLs to clean Markdown and plain text, with headings, tables, word count and optional images. For LLM, RAG and docs. No start fee. Failed or empty files are free. Empty input = free demo.

- **URL**: https://apify.com/ucchiii/docx-to-markdown.md
- **Developed by:** [Actor Factory](https://apify.com/ucchiii) (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

from $1.75 / 1,000 converted documents

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/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

You have a pile of Word files, contracts, reports, policies or exported wiki pages, and you need their text in a form a
program can use: Markdown for an LLM or a RAG index, plain text for search, a list of headings for navigation, tables you
can parse. Copy-pasting from Word loses the structure, and a desktop converter does not run on 500 links. This Actor takes
a list of **.docx links** and returns one row per file. No browser, no LLM, no API key.

**Try it free: leave the input empty and press Start.** The demo converts two built-in sample documents, needs no network
and is not charged (rows carry `_demo: true`).

| source | title | wordCount | headings | tables | status |
|---|---|---|---|---|---|
| sample-report.docx | Quarterly report (sample) | 39 | 3 | 1 | ok |
| sample-meeting-notes.docx | Meeting notes (sample) | 25 | 2 | 1 | ok |
| https://example.com/missing.docx | | 0 | 0 | 0 | error (`http_404`) |

### What you get

- **Markdown** with `#` headings, bullet and numbered lists, bold and italic, links and **GitHub-style tables**
- **Plain text**: one line per paragraph, table cells separated by tabs (can be turned off to keep rows small)
- **Headings list**: every heading as `{level, text}`, in order, for outlines and chunking
- **Tables as Markdown**: each table also as its own string in `tables`, so you can parse them separately
- **Title** from the file properties, else the first heading, else the first line
- **Word count** (characters for Japanese, Chinese and Korean text) and character count
- **Images** (off by default): saved to the key-value store and referenced in the Markdown as `![alt](key)`
- **.md files** (off by default): one Markdown file per document in the key-value store, with a link in the row
- **Max characters** per document, cut at a paragraph boundary, with a `truncated` flag
- Works for English and Japanese documents

### Price

**$2.50 per 1,000 documents** ($0.0025 per file converted), no start fee. 1,000 files cost $2.50, 10,000 files cost $25.
On the Apify Free plan, the $5 of monthly platform credit covers about **2,000 files** a month.
Only successful conversions are charged. Failed downloads (404, timeout, blocked), files that are not Word documents,
password-protected or empty files, and the demo are free.

### Input

```json
{
  "urls": ["https://example.com/reports/q3.docx"],
  "includeText": true,
  "extractImages": false,
  "saveMarkdownFiles": false,
  "maxChars": 0
}
```

Up to 5,000 links per run. Leave `urls` empty for the free demo.

### Output (one row per link)

```json
{
  "source": "https://example.com/reports/q3.docx",
  "title": "Quarterly report",
  "markdown": "# Quarterly report\n\n## Results\n\n| Region | Revenue |\n| --- | --- |\n| EMEA | $1.2M |",
  "text": "Quarterly report\nResults\nRegion\tRevenue\nEMEA\t$1.2M",
  "headings": [{"level": 1, "text": "Quarterly report"}, {"level": 2, "text": "Results"}],
  "tables": ["| Region | Revenue |\n| --- | --- |\n| EMEA | $1.2M |"],
  "wordCount": 8, "charCount": 82, "truncated": false,
  "imageCount": 0, "images": [], "markdownKey": null, "markdownUrl": null,
  "warnings": [], "status": "ok", "error": null
}
```

`status` is `ok`, `empty` (no text in the file) or `error`. `error` holds a short code: `http_404`, `timeout`, `dns_failure`,
`blocked_private_address`, `invalid_url`, `file_too_large`, `not_a_docx`, `encrypted`, `expanded_too_large`,
`too_many_entries`, `corrupt_docx` or `convert_failed: ...`. If a link redirected, `finalUrl` is added.
Counts are saved in the key-value store as `STATS`.

### Safety limits

- Only the links you list are downloaded, over `http://` or `https://`. Every redirect hop is checked; localhost, private
  and cloud-metadata addresses are refused
- Downloads over **20 MB** are refused. Files that expand to more than **60 MB**, have a part over 20 MB or more than 3,000
  entries are refused as possible zip bombs, before any parsing
- Links, remote images and external references inside a document are **never opened**; macros are never run
- Polite: at most 2 connections per host and 0.2 s between requests to the same host
- Not supported: old binary `.doc` files, password-protected files, OCR of pictures, headers/footers and text boxes
  (the main body, footnotes and tables are converted)

### Use cases

- Feed contracts, policies and reports to an LLM or a vector database (pair it with a chunker)
- Move a Word-based knowledge base to Markdown for a static site or wiki
- Index document titles and headings for search
- Pull tables out of Word reports into your own pipeline

### Notes

You are responsible for having the right to download and reuse the files you convert. The Actor adds no personal data;
if your documents contain personal data, handling it is up to you.

If this Actor saved you time, a rating on the Store helps others find it.

### More tools from the same developer

- [HTML to Markdown Converter for LLM and RAG](https://apify.com/ucchiii/html-to-markdown) — clean Markdown from URLs, raw HTML or datasets for LLM and RAG
- [PDF to Text Converter](https://apify.com/ucchiii/pdf-to-text) — plain text per page from public PDF URLs, plus one .txt file per PDF
- [RAG Chunker](https://apify.com/ucchiii/rag-chunker) — split scraped pages into chunks for RAG and vector stores
- [CSV to Excel Converter](https://apify.com/ucchiii/csv-xlsx-converter) — convert CSV, TSV, Excel XLSX, JSON and NDJSON files or Apify datasets into each other
- [Bulk File Downloader](https://apify.com/ucchiii/bulk-file-downloader) — download files from URL lists or dataset fields into storage, with links, SHA-256 and an optional ZIP

# Actor input Schema

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

Full links to .docx files, starting with http:// or https://. Only these files are downloaded; internal or private addresses are refused. Up to 5,000 files per run. Leave empty for a free demo.

## `includeText` (type: `boolean`):

Add a plain-text version of each document next to the Markdown. Turn off to make rows smaller.

## `extractImages` (type: `boolean`):

Save pictures from the document (PNG, JPEG, GIF and similar, up to 10 MB each and 200 per file) to the key-value store and reference them in the Markdown as ![alt](key). Off by default; images are otherwise dropped.

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

Also save each document's Markdown as a .md file in the key-value store and add its key and link to the row.

## `maxChars` (type: `integer`):

Cut the Markdown and text of each document at this length, at a paragraph boundary where possible (the row gets truncated: true). 0 means the built-in limit of 2,000,000 characters.

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

Refuse downloads larger than this many megabytes (file_too_large). Allowed range 1 to 20 (default 20).

## `timeoutSecs` (type: `integer`):

Timeout for each download, in seconds. Allowed range 1 to 120 (default 30).

## `concurrency` (type: `integer`):

How many files are downloaded in parallel. Allowed range 1 to 5 (default 3). At most 2 connections per host are used at a time, with at least 0.2 s between requests to the same host.

## `userAgent` (type: `string`):

Optional custom User-Agent header for downloads. Default identifies this Actor.

## Actor input object example

```json
{
  "urls": [
    "https://raw.githubusercontent.com/mwilliamson/python-mammoth/master/tests/test-data/tables.docx"
  ],
  "includeText": true,
  "extractImages": false,
  "saveMarkdownFiles": false,
  "maxChars": 0,
  "maxFileMb": 20,
  "timeoutSecs": 30,
  "concurrency": 3
}
```

# Actor output Schema

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

One item per file: source, title, markdown, text, headings, tables, wordCount, charCount, truncated, imageCount, images, markdownUrl, status (ok, empty or error) and error.

## `stats` (type: `string`):

Record STATS: counts of converted, empty and failed files and how many were charged.

# 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://raw.githubusercontent.com/mwilliamson/python-mammoth/master/tests/test-data/tables.docx"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("ucchiii/docx-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://raw.githubusercontent.com/mwilliamson/python-mammoth/master/tests/test-data/tables.docx"] }

# Run the Actor and wait for it to finish
run = client.actor("ucchiii/docx-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://raw.githubusercontent.com/mwilliamson/python-mammoth/master/tests/test-data/tables.docx"
  ]
}' |
apify call ucchiii/docx-to-markdown --silent --output-dataset

```

## MCP server setup

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