# Pandoc Document Converter - HTML to Markdown, DOCX, EPUB, PPTX (`scrapeworks/pandoc-document-converter`) Actor

Convert documents between formats with Pandoc in the cloud: HTML to Markdown for LLMs and RAG, Markdown to Word DOCX, EPUB e-books, PowerPoint PPTX, LaTeX, reStructuredText and more. Feed it URLs or raw text, get one converted document per input.

- **URL**: https://apify.com/scrapeworks/pandoc-document-converter.md
- **Developed by:** [Nicolas van Arkens](https://apify.com/scrapeworks) (community)
- **Categories:** Developer tools, Automation, Integrations
- **Stats:** 4 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 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.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Pandoc Document Converter — HTML to Markdown, Markdown to DOCX, EPUB, PPTX & more

Convert documents between formats in bulk, with no install and no servers — this Actor wraps **[Pandoc](https://pandoc.org)**, the universal document converter, and runs it in the cloud. Feed it **URLs** (it fetches them for you) and/or **raw text**, pick an output format, and get one converted document per input back.

Typical jobs it does in seconds:

- **HTML → Markdown** (turn web pages into clean Markdown for LLMs, RAG pipelines, or docs)
- **Markdown → DOCX** (deliver Word documents from generated text)
- **Markdown → EPUB** (package content as an e-book)
- **Markdown → PPTX** (headings become PowerPoint slides)
- LaTeX, reStructuredText, Org-mode, MediaWiki, Textile, DocBook, OPML, CSV in — Markdown, HTML, plain text, RTF, AsciiDoc, ODT and more out

### What data you get

One dataset row per converted document:

| Field | Description |
|---|---|
| `source` | The URL, or `text #N` for raw-text inputs |
| `ok` | `true` when conversion succeeded |
| `inputFormat` | The detected (or forced) source format |
| `outputFormat` | The format you requested |
| `output` | The converted document, inline — for text formats (Markdown, HTML, plain, LaTeX, …) |
| `outputCharacters` | Length of the inline output |
| `downloadUrl` | Direct download link — for binary formats (DOCX, PPTX, EPUB, ODT), stored in the run's key-value store |
| `outputBytes` | Size of the binary file |

You are only charged for successful conversions — failed fetches or conversions are reported with `ok: false` and never billed.

### Input example

```json
{
    "urls": ["https://example.com/"],
    "texts": ["# Quarterly report\n\nRevenue grew **18%** quarter over quarter.\n\n- New customers: 412\n- Churn: 2.1%"],
    "inputFormat": "auto",
    "outputFormat": "gfm"
}
```

`inputFormat: "auto"` detects HTML vs Markdown per item (Content-Type header, file extension, or content sniffing). Set it explicitly for LaTeX, RST, Org, MediaWiki, Textile, DocBook, OPML or CSV sources.

### Output sample (real run)

```json
{
    "source": "https://example.com/",
    "ok": true,
    "inputFormat": "html",
    "outputFormat": "gfm",
    "output": "# Example Domain\n\nThis domain is for use in documentation examples without needing permission. Avoid use in operations.\n\n[Learn more](https://iana.org/domains/example)\n",
    "outputCharacters": 192
}
```

And a binary conversion (Markdown → Word):

```json
{
    "source": "text #1",
    "ok": true,
    "inputFormat": "markdown",
    "outputFormat": "docx",
    "downloadUrl": "https://api.apify.com/v2/key-value-stores/%3Cstore-id%3E/records/converted-1.docx",
    "outputBytes": 10580
}
```

### Use cases

- **Feed web content to LLMs** — convert pages to GitHub-flavored Markdown (`gfm`) with `--wrap=none` applied automatically, ready for prompts, embeddings, or RAG ingestion.
- **Automated report delivery** — your pipeline produces Markdown; this Actor turns it into DOCX or PPTX your stakeholders actually open. Chain it after any scraper or AI Actor via Apify integrations.
- **Publishing workflows** — convert a batch of Markdown chapters or HTML articles into EPUB e-books, or migrate docs between wikis (MediaWiki ⇄ Markdown ⇄ reStructuredText).

### FAQ

**Which formats are supported?**
Input: HTML, Markdown (Pandoc / GitHub-flavored / CommonMark), LaTeX, reStructuredText, Org, MediaWiki, Textile, DocBook, OPML, CSV — or auto-detect. Output: Markdown (GFM / Pandoc / CommonMark), HTML, plain text, DOCX, PPTX, EPUB, ODT, RTF, reStructuredText, LaTeX, AsciiDoc, Org, MediaWiki, Textile, OPML.

**How do I get the DOCX / EPUB / PPTX files?**
Binary outputs are stored in the run's key-value store; each dataset row contains a direct `downloadUrl`. Text outputs come back inline in the dataset.

**Does it extract the article from a web page?**
No — it converts the page **verbatim**, exactly like running `pandoc` on the HTML. Navigation and boilerplate present in the HTML will be present in the output. For readability extraction, run a content-extraction Actor first and pipe its HTML here.

**Is PDF output supported?**
Not yet — PDF generation needs a LaTeX engine. Convert to DOCX or HTML and print/export to PDF, or ask for it in the Actor's Issues tab.

**What does it cost?**
A small fee per successfully converted document (pay-per-event). Failed items are never charged.

# Actor input Schema

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

Web pages or raw files to download and convert. Each URL becomes one converted document in the dataset. The input format is auto-detected from the response (HTML pages, .md files, etc.) unless you override it with 'Input format'.

## `texts` (type: `array`):

Raw document contents to convert (e.g. Markdown or HTML strings). Each entry becomes one converted document in the dataset. Use this when you already have the content and don't need fetching.

## `inputFormat` (type: `string`):

Format of the source documents. 'auto' detects HTML vs Markdown per item (from the HTTP Content-Type, file extension, or content). Set explicitly when converting LaTeX, reStructuredText, Org, MediaWiki, Textile, DocBook, OPML or CSV.

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

Format to convert every document into. Text formats (Markdown, HTML, plain text, LaTeX, ...) are returned inline in the dataset; binary formats (DOCX, PPTX, EPUB, ODT) are stored in the run's key-value store and the dataset row contains a direct download URL.

## `standalone` (type: `boolean`):

Produce a complete document with header and metadata (e.g. a full HTML page with <head>, or an RTF/LaTeX document that compiles on its own) instead of a fragment. Binary formats (DOCX, PPTX, EPUB, ODT) are always standalone.

## `documentTitle` (type: `string`):

Title metadata embedded in standalone and binary outputs (shown e.g. as the EPUB book title or DOCX document title). If empty, the source URL or 'Converted document' is used.

## Actor input object example

```json
{
  "urls": [
    "https://example.com/"
  ],
  "texts": [
    "# Hello\n\nThis is **Markdown** converted by Pandoc.\n\n- works with lists\n- and [links](https://pandoc.org)"
  ],
  "inputFormat": "auto",
  "outputFormat": "gfm",
  "standalone": false,
  "documentTitle": ""
}
```

# 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://example.com/"
    ],
    "texts": [
        "# Hello\n\nThis is **Markdown** converted by Pandoc.\n\n- works with lists\n- and [links](https://pandoc.org)"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("scrapeworks/pandoc-document-converter").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://example.com/"],
    "texts": ["""# Hello

This is **Markdown** converted by Pandoc.

- works with lists
- and [links](https://pandoc.org)"""],
}

# Run the Actor and wait for it to finish
run = client.actor("scrapeworks/pandoc-document-converter").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://example.com/"
  ],
  "texts": [
    "# Hello\\n\\nThis is **Markdown** converted by Pandoc.\\n\\n- works with lists\\n- and [links](https://pandoc.org)"
  ]
}' |
apify call scrapeworks/pandoc-document-converter --silent --output-dataset

```

## MCP server setup

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

```

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/pgb5MVS4XFWkcXIcB/builds/0akg9blNPvCAqSLyV/openapi.json
