# Document Format Converter — Markdown, HTML & Text (`junipr/document-format-converter`) Actor

Convert Markdown, HTML, plain text, JSON, and CSV-style documents into clean automation-ready formats with downloadable output files.

- **URL**: https://apify.com/junipr/document-format-converter.md
- **Developed by:** [junipr](https://apify.com/junipr) (community)
- **Categories:** Automation, Developer tools
- **Stats:** 2 total users, 1 monthly users, 55.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.20 / 1,000 document 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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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

## Document Format Converter — Markdown, HTML & Text

Convert documents between Markdown, HTML, EPUB, DOCX, PPTX, PDF, and more — powered by [Pandoc](https://pandoc.org/), the universal document conversion engine.

### What does Document Format Converter — Markdown, HTML & Text do?

This actor wraps the Pandoc document converter to provide a simple, API-accessible way to convert between dozens of document formats on Apify. No need to install Pandoc locally or manage command-line arguments — just provide your source text (or a URL to fetch from), pick your input and output formats, and get the converted document back.

**Supported input formats:** Markdown, HTML, reStructuredText, LaTeX, Textile, Org Mode, MediaWiki

**Supported output formats:** HTML, Markdown, EPUB, DOCX (Word), PPTX (PowerPoint), PDF, reStructuredText, LaTeX, Plain Text

### Key Features

- **Universal conversion** — 7 input formats × 9 output formats = 50+ conversion pairs
- **Real Pandoc engine** — not a JS polyfill. Full Pandoc binary with LaTeX support for PDF output
- **Fetch from URL** — provide a URL and the actor fetches the source content automatically
- **Table of contents** — auto-generate TOC for HTML, EPUB, and DOCX output
- **Standalone or fragment** — get a complete document or just the converted body
- **Advanced mode** — pass custom Pandoc CLI arguments for full control
- **Binary output support** — EPUB, DOCX, PPTX, and PDF files saved to key-value store with correct MIME types
- **Cost controls** — source content defaults to a 250,000 character cap and can be raised to 1,000,000 characters per run

### How to Use

#### Basic: Convert Markdown to HTML (zero config)
Run with no input to convert a built-in Markdown document to HTML.

#### Convert HTML to Markdown
```json
{
  "sourceUrl": "https://example.com/page.html",
  "inputFormat": "html",
  "outputFormat": "markdown"
}
````

#### Convert Markdown to EPUB

```json
{
  "sourceText": "# My Book\n\n## Chapter 1\n\nOnce upon a time...",
  "inputFormat": "markdown",
  "outputFormat": "epub",
  "tableOfContents": true
}
```

#### Convert to Word Document

```json
{
  "sourceText": "# Report Title\n\n## Summary\n\nKey findings...",
  "inputFormat": "markdown",
  "outputFormat": "docx"
}
```

### Input Parameters

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `sourceText` | string | Built-in Markdown | Source document text to convert |
| `sourceUrl` | string | — | URL to fetch source content (overrides sourceText) |
| `inputFormat` | enum | `markdown` | Source format: markdown, html, rst, latex, textile, org, mediawiki |
| `outputFormat` | enum | `html` | Target format: html, markdown, epub, docx, pptx, pdf, rst, latex, plain |
| `standalone` | boolean | `true` | Produce a complete standalone document |
| `tableOfContents` | boolean | `false` | Include auto-generated table of contents |
| `customArgs` | string | — | Additional Pandoc CLI arguments for advanced users |
| `maxSourceCharacters` | integer | `250000` | Maximum source characters per run, capped at 1,000,000 |

### Output

**Text formats** (HTML, Markdown, RST, LaTeX, Plain): Output is included directly in the dataset and saved to the key-value store.

**Binary formats** (EPUB, DOCX, PPTX, PDF): Output is saved to the key-value store. The dataset entry contains metadata including the key-value store key to access the file.

#### Example Output (Markdown → HTML)

```json
{
  "inputFormat": "markdown",
  "outputFormat": "html",
  "inputLength": 842,
  "outputType": "text",
  "outputLength": 1456,
  "outputKey": "OUTPUT.html",
  "output": "<!DOCTYPE html>...",
  "standalone": true,
  "tableOfContents": false,
  "convertedAt": "2026-03-11T12:00:00.000Z"
}
```

### Use Cases

- **Documentation pipelines** — Convert Markdown docs to HTML, EPUB, or PDF for distribution
- **Content migration** — Transform HTML pages to Markdown for static site generators
- **Report generation** — Convert Markdown reports to Word or PowerPoint
- **E-book creation** — Build EPUB files from Markdown manuscripts
- **Format standardization** — Convert MediaWiki, RST, or Org Mode content to Markdown

#### How much does it cost?

This actor uses pay-per-event pricing with the `document-converted` event. Each successful document conversion is one billable event in the live Store pricing entry.

#### Can I convert very large documents?

The actor defaults to 250,000 source characters and supports up to 1,000,000 characters per run. Conversion timeout is 300 seconds. For very large or complex LaTeX documents, split the source into smaller runs.

#### What version of Pandoc is used?

The actor uses the Pandoc version available in the Debian repositories (typically 2.x+). For most conversions this is fully sufficient. If you need a specific Pandoc version or feature, mention it in the `customArgs` field.

### Pricing

This actor uses Pay-Per-Event (PPE) pricing with the `document-converted` event: **$5.20 per 1,000 documents converted** ($0.0052 per document) in the live Store pricing entry.

Apify platform usage follows the live Store pricing entry.

### Related Actors

- [Markdown to HTML Converter](https://apify.com/junipr/markdown-to-html) — Specialized Markdown→HTML with syntax highlighting and themes
- [PDF to HTML Converter](https://apify.com/junipr/pdf-to-html) — PDF→HTML with layout preservation
- [PDF to Text Extractor](https://apify.com/junipr/pdf-to-text-extractor) — Extract text from PDFs
- [PDF OCR Tool](https://apify.com/junipr/pdf-ocr-tool) — OCR extraction from scanned PDFs
- [JSON to CSV Converter](https://apify.com/junipr/json-to-csv-converter) — Convert JSON data to CSV

# Actor input Schema

## `sourceText` (type: `string`):

The source document content to convert. If empty, a built-in Markdown document is used.

## `sourceUrl` (type: `string`):

URL to fetch source content from. Overrides sourceText if provided.

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

Format of the source content.

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

Target format for conversion.

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

Produce a complete standalone document (with header/footer). Disable for fragment-only output.

## `tableOfContents` (type: `boolean`):

Include an auto-generated table of contents in the output.

## `customArgs` (type: `string`):

Additional Pandoc CLI arguments for advanced users (space-separated). Example: --highlight-style=tango --number-sections

## `maxSourceCharacters` (type: `integer`):

Maximum source characters to fetch or convert in this run. Capped to avoid runaway document conversions.

## Actor input object example

```json
{
  "sourceText": "# Conversion Example\n\nThis bounded document proves Markdown-to-HTML conversion.",
  "sourceUrl": "",
  "inputFormat": "markdown",
  "outputFormat": "html",
  "standalone": true,
  "tableOfContents": false,
  "customArgs": "",
  "maxSourceCharacters": 250000
}
```

# Actor output Schema

## `convertedDocument` (type: `string`):

The converted document and conversion metadata

# 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 = {
    "sourceText": `# Conversion Example

This bounded document proves Markdown-to-HTML conversion.`
};

// Run the Actor and wait for it to finish
const run = await client.actor("junipr/document-format-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 = { "sourceText": """# Conversion Example

This bounded document proves Markdown-to-HTML conversion.""" }

# Run the Actor and wait for it to finish
run = client.actor("junipr/document-format-converter").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "sourceText": "# Conversion Example\\n\\nThis bounded document proves Markdown-to-HTML conversion."
}' |
apify call junipr/document-format-converter --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=junipr/document-format-converter",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Document Format Converter — Markdown, HTML & Text",
        "description": "Convert Markdown, HTML, plain text, JSON, and CSV-style documents into clean automation-ready formats with downloadable output files.",
        "version": "1.0",
        "x-build-id": "19a0ARWDhbolnpgFt"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/junipr~document-format-converter/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-junipr-document-format-converter",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/junipr~document-format-converter/runs": {
            "post": {
                "operationId": "runs-sync-junipr-document-format-converter",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/junipr~document-format-converter/run-sync": {
            "post": {
                "operationId": "run-sync-junipr-document-format-converter",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "sourceText": {
                        "title": "Source Text",
                        "type": "string",
                        "description": "The source document content to convert. If empty, a built-in Markdown document is used.",
                        "default": "# Conversion Example\n\nThis bounded document proves Markdown-to-HTML conversion."
                    },
                    "sourceUrl": {
                        "title": "Source URL",
                        "type": "string",
                        "description": "URL to fetch source content from. Overrides sourceText if provided.",
                        "default": ""
                    },
                    "inputFormat": {
                        "title": "Input Format",
                        "enum": [
                            "markdown",
                            "html",
                            "rst",
                            "latex",
                            "textile",
                            "org",
                            "mediawiki"
                        ],
                        "type": "string",
                        "description": "Format of the source content.",
                        "default": "markdown"
                    },
                    "outputFormat": {
                        "title": "Output Format",
                        "enum": [
                            "html",
                            "markdown",
                            "epub",
                            "docx",
                            "pptx",
                            "pdf",
                            "rst",
                            "latex",
                            "plain"
                        ],
                        "type": "string",
                        "description": "Target format for conversion.",
                        "default": "html"
                    },
                    "standalone": {
                        "title": "Standalone Document",
                        "type": "boolean",
                        "description": "Produce a complete standalone document (with header/footer). Disable for fragment-only output.",
                        "default": true
                    },
                    "tableOfContents": {
                        "title": "Table of Contents",
                        "type": "boolean",
                        "description": "Include an auto-generated table of contents in the output.",
                        "default": false
                    },
                    "customArgs": {
                        "title": "Custom Pandoc Arguments",
                        "type": "string",
                        "description": "Additional Pandoc CLI arguments for advanced users (space-separated). Example: --highlight-style=tango --number-sections",
                        "default": ""
                    },
                    "maxSourceCharacters": {
                        "title": "Max Source Characters",
                        "minimum": 1000,
                        "maximum": 1000000,
                        "type": "integer",
                        "description": "Maximum source characters to fetch or convert in this run. Capped to avoid runaway document conversions.",
                        "default": 250000
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
