# Document to Text & Markdown: DOCX XLSX PPTX \[USD 0.7/1K] (`usefulapi/document-to-text`) Actor

Turn Word, Excel, PowerPoint, OpenDocument, EPUB, RTF and HTML documents into clean text and Markdown with headings, lists and tables. USD 0.70 per 1,000 documents plus USD 0.60 per 1,000 MB beyond the first MB.

- **URL**: https://apify.com/usefulapi/document-to-text.md
- **Developed by:** [Useful API](https://apify.com/usefulapi) (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

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 Text & Markdown: Word, Excel, PowerPoint, OpenDocument, EPUB, RTF

Give it links to documents, get back clean text and Markdown: headings, lists, tables as Markdown tables, slide numbers
and sheet names. DOCX, XLSX, PPTX, ODT, ODS, ODP, EPUB, RTF, HTML, TXT and CSV in one run.

PDFs are not read here: they get a free row that points to the
[PDF Text Extractor with OCR](https://apify.com/usefulapi/pdf-text-ocr).

### What you get

- **The format is read from the file's bytes**, not from its extension or the server's Content-Type. A `.xlsx` link that
  serves a Word file is read as Word.
- **Markdown that keeps the structure.** Word: headings (from styles and outline levels), numbered and bullet lists with
  their levels, tables, links, bold and italic, footnotes. Excel and OpenDocument spreadsheets: one table per sheet,
  dates written as dates. PowerPoint and OpenDocument presentations: `## Slide N: title`, bullet levels, tables and
  speaker notes. EPUB: chapters in reading order. RTF: paragraphs, tables, lists, Unicode and code pages.
- **Plain text too** (`text`), or only one of the two (`outputText`, `outputMarkdown`).
- **No author names.** Metadata is title, subject, description, keywords, language and dates. The creator, last modified
  by and company fields are never read.
- **One bad file never stops the run.** A dead link, a damaged file or a hostile one gets a row with a clear `status`.
- **Safe on hostile files.** Zip bombs (too many entries, huge or extreme-ratio parts, nested archives) and XML entity
  attacks are refused or ignored, and every file is read in a worker that is killed at a time cap.

### Input

```json
{
  "urls": [
    { "url": "https://assets.publishing.service.gov.uk/media/66f66e4630536cb927482873/Pupil_premium_strategy_statement_blank_template.docx" },
    { "url": "https://www2.census.gov/programs-surveys/popest/tables/2020-2025/state/totals/NST-EST2025-POP.xlsx" }
  ],
  "outputMarkdown": true,
  "outputText": true
}
```

| Field | Default | What it does |
|---|---|---|
| `urls` | | Direct links to documents (one per entry, or one per line in text) |
| `outputText`, `outputMarkdown` | both on | Which of the two to return (at least one) |
| `includeHiddenSheets` | off | Spreadsheets: also read sheets hidden in Excel or LibreOffice |
| `maxFileSizeMb` | 25 | Larger files are not read (status `too_large`). Up to 100 |
| `maxCharsPerDocument` | 1,000,000 | Text and Markdown are each cut here (one dataset item holds at most 9 MB). The row says when it was cut |
| `maxDocuments` | | Reads at most this many links |
| `concurrency` | 2 | Documents downloaded at once (at most 2 per host). At most 2 are read at once whatever you set (memory), and the Actor has a quarter of a CPU core per GB: raise it only for slow servers |

A file in your own Apify storage works through its signed share link (a plain storage URL is refused, `forbidden`).

### Output

One row per link. Example (text and Markdown shortened):

```json
{
  "input": "https://assets.publishing.service.gov.uk/media/68e756a48c1db6022d0ca27f/Example_pupil_premium_strategy_statement_primary_2025.docx",
  "fileName": "Example_pupil_premium_strategy_statement_primary_2025.docx",
  "httpStatus": 200,
  "fileSizeBytes": 78262,
  "sha256": "161abaea9ce4eaac2fab7c8fbc6b83fdafb3f32191697b62bcb9b922e3c132e4",
  "status": "ok",
  "format": "docx",
  "title": "Example pupil premium strategy primary statement - primary",
  "createdAt": "2025-08-05T09:24:00Z",
  "modifiedAt": "2025-10-09T06:29:00Z",
  "pageCount": 11,
  "wordCount": 2928,
  "characterCount": 19536,
  "truncated": false,
  "text": "Pupil premium example statement (primary)\n\nThe pupil premium statement below is ...",
  "markdown": "# Pupil premium example statement (primary)\n\nThe pupil premium statement below is ...",
  "notes": [],
  "billed": { "document": 1 }
}
```

The field names match the [PDF Actor](https://apify.com/usefulapi/pdf-text-ocr) where they mean the same thing
(`fileName`, `fileSizeBytes`, `sha256`, `status`, `error`, `title`, `createdAt`, `modifiedAt`, `pageCount`, `text`,
`markdown`, `billed`), so the two can be swapped in one pipeline. Other fields: `format`, `subject`, `description`,
`keywords`, `language`, `slideCount`, `sheetCount`, `sectionCount` (EPUB chapters), `wordCount`, `characterCount`,
`truncated`, `notes` (anything to know about this file), `httpStatus`, `checkedAt`. `pageCount` is the number the file
itself states (Word and ODT), not a layout calculation, and is empty when the file does not say.

#### Statuses

`ok`, `not_found`, `forbidden`, `rate_limited`, `server_error`, `http_error`, `unreachable`, `dns_not_found`,
`tls_error` (the site's certificate or secure connection could not be verified; nothing is read over it), `timeout`,
`too_slow` (a server that sends under 200 KB/s after a 12 s allowance), `too_large`, `empty`, `corrupt`,
`password_protected`, `unsafe_document` (zip bomb or too deeply nested XML), `unsupported_format` (old binary Office
files DOC, XLS, PPT and password-protected Office files, images, archives, programs), `unsupported_use_pdf_actor`,
`cost_limit` (your maximum cost per run would have been passed, or the file could not finish before the run's timeout),
`private_address` (the host name points to a private or reserved address; not fetched), `blocked_port` (only ports 80,
443, 8080 and 8443 are fetched), `invalid_input`, `error`. The run's `OUTPUT` record
counts rows by status and lists the events billed.

A link that returns a web page (a landing page, a viewer page) is read as HTML and the row says so in `notes`.
Scripts are not run, so text a page builds with JavaScript is not seen (such a page gets status `empty`).

### Pricing (pay per event)

| Event | Price | Per 1,000 | What it is |
|---|---|---|---|
| `apify-actor-start` | USD 0.003 per run | | Charged by Apify at the start (1 GB of memory) |
| `document` | USD 0.0007 | **USD 0.70** | A document that was read |
| `document-megabyte` | USD 0.0006 | USD 0.60 | Each started MB of a file beyond its first MB |
| `document-checked` | USD 0.0002 | USD 0.20 | A link where nothing was read (dead link, damaged or empty file, a format that is not read, too large, timeout) |

PDFs, invalid entries and a file the Actor stops before reading it because the run has not yet earned its cost are free. The megabyte event is also charged on `document-checked` rows when the file was
downloaded (the time to fetch and read it was spent).

Worked examples (from platform runs, see PRICING.md): 76 mixed documents in one run (74 read, a PDF, a dead link, 10.6 MB
in all) cost USD 0.003 + 74 x 0.0007 + 1 x 0.0002 = **USD 0.0550**. Seven large spreadsheets, decks and a book (13.65 MB
in all) cost USD 0.003 + 7 x 0.0007 + 10 x 0.0006 = USD 0.0139.

Set a maximum cost per run in the run options: the Actor stops cleanly just below it and keeps every row it has billed.

### Limits (what it does not do)

- Old binary Office files (DOC, XLS, PPT) and password-protected Office files are not read. Save them as DOCX, XLSX or
  PPTX without a password. There is no OCR: text inside pictures is not read, and pictures, charts and SmartArt text are
  left out.
- Headers, footers, comments and tracked deletions are left out (Word, OpenDocument and RTF). Text boxes are read.
- A plain text, CSV or JSON file is read up to what `maxCharsPerDocument` can hold (about 4 bytes per character), and a
  web page up to 20 bytes per character: the rest of a very large file is not read (`truncated`: true, with a note).
- Spreadsheets: values are written as stored, only dates are formatted (so a percentage cell reads 0.25 and a currency
  cell reads its number). Merged cells show their value once. Formulas show the result the file saved.
  Hidden sheets are skipped unless you ask. A sheet is cut at 200,000 rows and 500 columns.
- PowerPoint: text comes in the order the shapes are stored in the file, which is not always the visual order.
- Files are downloaded as you give them: the Actor does not read `robots.txt` for a direct file link (as with the
  [Bulk File Downloader](https://apify.com/usefulapi/bulk-file-downloader)). It identifies itself as `UsefulApiBot` and
  never as a browser; a server that refuses it gets a `forbidden` row.
- A share link that opens a viewer page (Google Drive, Dropbox, SharePoint) returns a web page, not the file: use the
  direct download link.
- One dataset item holds at most 9 MB, so a very large document is cut (`truncated`: true).

### FAQ

**Does it send my documents anywhere?** No. Files are read inside the run with open-source libraries; nothing is sent to
any AI or OCR service.

**Which libraries?** `yauzl` (zip), `htmlparser2` (XML and HTML). The Word, Excel, PowerPoint, OpenDocument, EPUB and RTF
readers are written for this Actor.

**Why did a 12 MB spreadsheet cost more than a 100 KB one?** The first MB is in the document price; each further started
MB is USD 0.0006.

**Related:** [PDF Text Extractor with OCR](https://apify.com/usefulapi/pdf-text-ocr) for PDFs and scans,
[Bulk File Downloader](https://apify.com/usefulapi/bulk-file-downloader) to fetch and check files first.

# Actor input Schema

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

Direct links to documents: Word (DOCX), Excel (XLSX), PowerPoint (PPTX), OpenDocument (ODT, ODS, ODP), EPUB, RTF, HTML, TXT or CSV. The format is read from the file's bytes, not its extension. PDFs get a free row that points to the PDF Actor. A file in your own Apify storage works through its signed share link.

## `outputText` (type: `boolean`):

Include the plain text of each document.

## `outputMarkdown` (type: `boolean`):

Include Markdown: headings, lists, tables as Markdown tables, slide numbers, sheet names.

## `includeHiddenSheets` (type: `boolean`):

Spreadsheets: also read sheets that are hidden in Excel or LibreOffice.

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

Larger files are not downloaded and get a too_large row. Up to 100.

## `maxCharsPerDocument` (type: `integer`):

Text and Markdown are each cut at this many characters (a dataset item holds at most 9 MB). The row says when it was cut.

## `maxDocuments` (type: `integer`):

Reads at most this many links (after dropping duplicates).

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

How many documents are downloaded in parallel (at most 2 per host). At most 2 are read at once whatever you set (memory), and the Actor has one quarter of a CPU core per GB: raise it only for slow servers.

## Actor input object example

```json
{
  "urls": [
    {
      "url": "https://assets.publishing.service.gov.uk/media/66f66e4630536cb927482873/Pupil_premium_strategy_statement_blank_template.docx"
    },
    {
      "url": "https://www2.census.gov/programs-surveys/popest/tables/2020-2025/state/totals/NST-EST2025-POP.xlsx"
    }
  ],
  "outputText": true,
  "outputMarkdown": true,
  "includeHiddenSheets": false,
  "maxFileSizeMb": 25,
  "maxCharsPerDocument": 1000000,
  "concurrency": 2
}
```

# Actor output Schema

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

One row per link: status, format, text and Markdown.

## `summary` (type: `string`):

Counts by status, billed events and why the run stopped, if it did.

# 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": [
        {
            "url": "https://assets.publishing.service.gov.uk/media/66f66e4630536cb927482873/Pupil_premium_strategy_statement_blank_template.docx"
        },
        {
            "url": "https://www2.census.gov/programs-surveys/popest/tables/2020-2025/state/totals/NST-EST2025-POP.xlsx"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("usefulapi/document-to-text").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": [
        { "url": "https://assets.publishing.service.gov.uk/media/66f66e4630536cb927482873/Pupil_premium_strategy_statement_blank_template.docx" },
        { "url": "https://www2.census.gov/programs-surveys/popest/tables/2020-2025/state/totals/NST-EST2025-POP.xlsx" },
    ] }

# Run the Actor and wait for it to finish
run = client.actor("usefulapi/document-to-text").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": [
    {
      "url": "https://assets.publishing.service.gov.uk/media/66f66e4630536cb927482873/Pupil_premium_strategy_statement_blank_template.docx"
    },
    {
      "url": "https://www2.census.gov/programs-surveys/popest/tables/2020-2025/state/totals/NST-EST2025-POP.xlsx"
    }
  ]
}' |
apify call usefulapi/document-to-text --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,usefulapi/document-to-text"
        }
    }
}
```

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/c4NiifenD6RhZfHbu/builds/7YG36Qg9xZJWnYlBf/openapi.json
