# Markdown to HTML Converter (`junipr/markdown-to-html`) Actor

Convert Markdown to styled HTML with GFM support, syntax highlighting, tables, task lists. Choose GitHub, Dark, or Minimal theme. Code blocks with language highlighting. Full document or fragment output.

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

## Pricing

from $1.30 / 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

## Markdown to HTML Converter

### What does Markdown to HTML Converter do?

Markdown to HTML Converter transforms Markdown text into styled, ready-to-use HTML. Provide Markdown content directly or point to a URL containing a Markdown file, and the actor produces a complete HTML document with your choice of theme, syntax highlighting for code blocks, and support for GitHub Flavored Markdown features like tables, task lists, and strikethrough text.

The output can be a full HTML document with `<!DOCTYPE html>` wrapper or a bare HTML fragment for embedding into existing pages. Two built-in themes are available (GitHub and Minimal), plus the option to inject custom CSS. The converted HTML is saved to the key-value store for direct download and also pushed to the dataset with conversion metadata.

### Features

- **Two input methods** — paste Markdown directly or fetch from a URL
- **Safety caps** — default max input size is 100,000 characters, configurable up to 250,000
- **GitHub Flavored Markdown** — tables, task lists, strikethrough, autolinks, and line breaks
- **Syntax highlighting** — automatic code block highlighting powered by highlight.js with language detection
- **Built-in themes** — GitHub theme (clean, modern, familiar) or Minimal theme (serif, reading-focused)
- **Custom CSS** — inject additional CSS for branding or custom styling
- **Fragment or document** — output a complete HTML page or just the HTML body fragment
- **Zero-config** — runs with a sample Markdown document if no input is provided
- **Direct download** — HTML output saved to key-value store as a downloadable file
- **Pay-per-conversion pricing** — charged per document converted

### Input Configuration

```json
{
  "markdown": "# Hello World\n\nThis is **bold** and *italic* text.\n\n```javascript\nconsole.log('Hello!');\n```",
  "markdownUrl": "",
  "maxMarkdownCharacters": 100000,
  "theme": "github",
  "includeStyles": true,
  "syntaxHighlight": true,
  "wrapInHtmlDocument": true,
  "gfm": true,
  "customCss": ""
}
````

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `markdown` | string | `""` | Raw Markdown text to convert. Takes priority over `markdownUrl`. |
| `markdownUrl` | string | `""` | URL to a Markdown file to fetch and convert |
| `maxMarkdownCharacters` | integer | `100000` | Maximum markdown characters per run, capped at 250,000 |
| `theme` | string | `"github"` | CSS theme: `github`, `minimal`, or `none` |
| `includeStyles` | boolean | `true` | Include CSS styles in the output |
| `syntaxHighlight` | boolean | `true` | Enable code block syntax highlighting |
| `wrapInHtmlDocument` | boolean | `true` | Wrap output in a complete HTML document. Set to false for HTML fragment. |
| `gfm` | boolean | `true` | Enable GitHub Flavored Markdown (tables, task lists, strikethrough) |
| `customCss` | string | `""` | Additional CSS to append to the output |

### Output Format

The dataset contains conversion metadata and the full HTML output:

```json
{
  "inputLength": 245,
  "outputLength": 1847,
  "theme": "github",
  "syntaxHighlight": true,
  "gfm": true,
  "wrapInHtmlDocument": true,
  "html": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>...</head>\n<body>\n<article class=\"markdown-body\">\n<h1>Hello World</h1>\n<p>This is <strong>bold</strong> and <em>italic</em> text.</p>\n</article>\n</body>\n</html>",
  "scrapedAt": "2026-03-11T12:00:00.000Z"
}
```

The complete HTML file is also saved to the key-value store under the key `OUTPUT` with content type `text/html`, making it directly downloadable and viewable in a browser.

### Usage Examples / Use Cases

- **Documentation publishing** — convert Markdown docs, READMEs, and changelogs to styled HTML pages
- **Blog content** — transform Markdown blog posts into HTML with syntax-highlighted code blocks
- **Email templates** — generate HTML fragments from Markdown for use in email campaigns
- **Static site generation** — batch-convert Markdown files to HTML as part of a build pipeline
- **Report formatting** — produce presentable HTML reports from Markdown source files
- **Apify pipeline step** — chain with other actors to convert scraped Markdown content to HTML

### Pricing

This actor uses Pay-Per-Event (PPE) pricing: **$1.30 per 1,000 documents converted** ($0.0013 per event).

Pricing includes all platform compute costs — no hidden fees.

### FAQ

#### What is the difference between the GitHub and Minimal themes?

The GitHub theme replicates the look of GitHub's Markdown rendering with a sans-serif font, 980px max width, bordered headings, and striped tables. The Minimal theme uses a serif font (Georgia), narrower 700px width, and a cleaner reading-focused layout. Choose `none` for unstyled HTML and provide your own CSS via the `customCss` field.

#### Does this sanitize raw HTML inside Markdown?

No. This actor converts Markdown to HTML and preserves raw inline HTML supported by the Markdown parser. If you render output from untrusted users in a browser, sanitize the HTML in your application before embedding it.

#### Can I get just the HTML body without the full document wrapper?

Yes. Set `wrapInHtmlDocument` to `false` and the actor will output only the HTML body content (with optional `<style>` block). This is useful when you need to embed the converted HTML inside an existing page or template.

#### What programming languages are supported for syntax highlighting?

The actor uses highlight.js, which supports over 190 programming languages. If a language is specified in the Markdown code fence (e.g., ` ```python `), it uses that language's highlighter. If no language is specified, highlight.js automatically detects the language.

#### Does this actor need a proxy?

No. Markdown to HTML Converter is a document transformation tool. When fetching from a URL, it makes a single HTTP request to download the Markdown file. No proxy is needed and it works on any Apify plan including the free tier.

#### Can I convert multiple Markdown files in one run?

The actor processes one Markdown document per run. For batch conversion, use the Apify API to trigger multiple runs programmatically, or chain it with another actor that produces Markdown content.

### Related Actors

- [JSON to CSV Converter](https://apify.com/junipr/json-to-csv-converter) — convert JSON data to CSV or TSV format
- [PDF to HTML Converter](https://apify.com/junipr/pdf-to-html) — convert PDF documents to structured HTML
- [RAG Web Extractor](https://apify.com/junipr/rag-web-extractor) — extract clean Markdown content from web pages for AI pipelines
- [Image to PDF Converter](https://apify.com/junipr/image-to-pdf) — convert images to PDF documents
- [PDF to Text Extractor](https://apify.com/junipr/pdf-to-text-extractor) — extract plain text from PDF files

# Actor input Schema

## `markdown` (type: `string`):

Raw markdown text to convert. If both markdown and markdownUrl are provided, markdown takes priority.

## `markdownUrl` (type: `string`):

URL to a markdown file to fetch and convert.

## `theme` (type: `string`):

CSS theme for the HTML output.

## `includeStyles` (type: `boolean`):

Include CSS styles in the output.

## `syntaxHighlight` (type: `boolean`):

Enable code syntax highlighting.

## `wrapInHtmlDocument` (type: `boolean`):

Wrap output in a complete HTML document (<!DOCTYPE html>). Disable for HTML fragment only.

## `gfm` (type: `boolean`):

Enable GFM extensions (tables, task lists, strikethrough).

## `customCss` (type: `string`):

Additional CSS to include in the output.

## `maxMarkdownCharacters` (type: `integer`):

Maximum markdown characters to fetch or convert in this run. Capped to keep output predictable.

## Actor input object example

```json
{
  "markdown": "",
  "markdownUrl": "",
  "theme": "github",
  "includeStyles": true,
  "syntaxHighlight": true,
  "wrapInHtmlDocument": true,
  "gfm": true,
  "customCss": "",
  "maxMarkdownCharacters": 100000
}
```

# Actor output Schema

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

The converted HTML document is saved to the key-value store as OUTPUT.

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("junipr/markdown-to-html").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("junipr/markdown-to-html").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 '{}' |
apify call junipr/markdown-to-html --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Markdown to HTML Converter",
        "description": "Convert Markdown to styled HTML with GFM support, syntax highlighting, tables, task lists. Choose GitHub, Dark, or Minimal theme. Code blocks with language highlighting. Full document or fragment output.",
        "version": "1.0",
        "x-build-id": "zHFV9AQwXmDqwTEaB"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/junipr~markdown-to-html/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-junipr-markdown-to-html",
                "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~markdown-to-html/runs": {
            "post": {
                "operationId": "runs-sync-junipr-markdown-to-html",
                "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~markdown-to-html/run-sync": {
            "post": {
                "operationId": "run-sync-junipr-markdown-to-html",
                "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": {
                    "markdown": {
                        "title": "Markdown Content",
                        "type": "string",
                        "description": "Raw markdown text to convert. If both markdown and markdownUrl are provided, markdown takes priority.",
                        "default": ""
                    },
                    "markdownUrl": {
                        "title": "Markdown URL",
                        "type": "string",
                        "description": "URL to a markdown file to fetch and convert.",
                        "default": ""
                    },
                    "theme": {
                        "title": "Theme",
                        "enum": [
                            "github",
                            "minimal",
                            "none"
                        ],
                        "type": "string",
                        "description": "CSS theme for the HTML output.",
                        "default": "github"
                    },
                    "includeStyles": {
                        "title": "Include Styles",
                        "type": "boolean",
                        "description": "Include CSS styles in the output.",
                        "default": true
                    },
                    "syntaxHighlight": {
                        "title": "Syntax Highlighting",
                        "type": "boolean",
                        "description": "Enable code syntax highlighting.",
                        "default": true
                    },
                    "wrapInHtmlDocument": {
                        "title": "Wrap in HTML Document",
                        "type": "boolean",
                        "description": "Wrap output in a complete HTML document (<!DOCTYPE html>). Disable for HTML fragment only.",
                        "default": true
                    },
                    "gfm": {
                        "title": "GitHub Flavored Markdown",
                        "type": "boolean",
                        "description": "Enable GFM extensions (tables, task lists, strikethrough).",
                        "default": true
                    },
                    "customCss": {
                        "title": "Custom CSS",
                        "type": "string",
                        "description": "Additional CSS to include in the output.",
                        "default": ""
                    },
                    "maxMarkdownCharacters": {
                        "title": "Max Markdown Characters",
                        "minimum": 1000,
                        "maximum": 250000,
                        "type": "integer",
                        "description": "Maximum markdown characters to fetch or convert in this run. Capped to keep output predictable.",
                        "default": 100000
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
