---
title: "Convert Markdown & HTML API"
slug: convert-markdown-html
url: https://apyhub.com/martin10291/service/convert-markdown-html
provider: Martin Petrov
categories: [Output Kit]
tags: [markdown, html-conversion, content-transform, document-formatting, toc-generation]
auth: api_key
version: 1.0
service_type: sync
endpoints: 1
atoms: 100
mcp: true
---

# Convert Markdown & HTML API

Markdown to HTML API: send Markdown or HTML and get back clean HTML or Markdown, plus a table of contents and word stats. Free tier, no card.

## Endpoints

| Method | URL | Description | Atoms |
| --- | --- | --- | --- |
| POST | `https://api.eu.apyhub.com/martin10291/convert-markdown-html/markdown-html-converter` | What it does Converts Markdown to HTML or HTML to Markdown, or detects the direction when you send… | 100 |

## Endpoint reference

### Convert Markdown & HTML API

`POST https://api.eu.apyhub.com/martin10291/convert-markdown-html/markdown-html-converter` · 100 atoms · accepts `application/json` · returns `application/json`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `to` | body | string | no | Target format when you send 'text'. One of: html, markdown, auto. Default: `auto`. Example: `auto`. |
| `toc` | body | boolean | no | Markdown to HTML: return the table of contents (level, text and anchor id of every heading). Example: `true`. |
| `html` | body | string | no | HTML to convert to Markdown, a whole page or a fragment. Max 1,000,000 characters. Example: `<html><head><title>Hello</title></head><body><nav>Menu</nav><article><h1>Hello…`. |
| `text` | body | string | no | Any text, used instead of markdown or html. The direction is detected automatically unless you set 'to'. Example: `# Hello world

This is **bold**.`. |
| `title` | body | string | no | Markdown to HTML with fullPage: the page <title>. Default: the first H1. Example: `Release notes`. |
| `fullPage` | body | boolean | no | Markdown to HTML: return a complete HTML page (doctype, title, readable CSS) instead of a fragment. Default: `false`. Example: `false`. |
| `markdown` | body | string | no | Markdown text to convert to HTML (GitHub-style tables, task lists, strikethrough, fenced code). Max 1,000,000 characters. Example: `# Release notes

Version **2.1** is out. See [docs](https://example… |
| `mainContent` | body | boolean | no | HTML to Markdown: keep only the main article text (drops navigation, footer, sidebars, cookie banners). Default: `false`. Example: `false`. |

#### Quickstart

Convert a short Markdown snippet to HTML.

```bash
curl -X POST "https://api.eu.apyhub.com/martin10291/convert-markdown-html/markdown-html-converter" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"markdown":"# Hello world\n\nThis is **bold**."}'
```

#### What you'll get back

Returns a JSON object with `count` and `items`. The single item holds the converted `html`, the `title` (the first heading), a `toc` with every heading and its anchor id, and `stats` about the text. If you send `html` instead, the item holds `markdown` and `content` in place of `html`.

```json
{
  "count": 1,
  "items": [
    {
      "from": "markdown",
      "to": "html",
      "title": "Hello world",
      "html": "<h1 id=\"hello-world\">Hello world</h1>\n<p>This is <strong>bold</strong>.</p>",
      "toc": [
        { "id": "hello-world", "level": 1, "text": "Hello world" }
      ],
      "stats": {
        "codeBlocks": 0,
        "estTokensIn": 8,
        "estTokensOut": 19,
        "headings": 1,
        "images": 0,
        "inputChars": 32,
        "links": 0,
        "outputChars": 75,
        "tables": 0,
        "words": 6
      },
      "ms": 0.2
    }
  ]
}
```

## About

## What it does
The Markdown to HTML API converts Markdown into HTML, and HTML back into Markdown, from one endpoint. Send your text and get back the converted content, the document title, a table of contents and size statistics.

To render Markdown, send it in `markdown`. The output supports GitHub-style tables, task lists, strikethrough and fenced code blocks. Set `toc` to `true` to get every heading with its level and anchor id. Set `fullPage` to `true` to get a complete HTML page with a doctype and readable CSS, and use `title` to set its page title. Raw HTML inside the Markdown is shown as text, and `javascript:` and `data:` links are replaced with `#`.

To go the other way, send a page or fragment in `html`. Set `mainContent` to `true` to keep only the main article and drop menus, sidebars and footers. If you are not sure which format you have, send it in `text` and set `to` to `html`, `markdown` or `auto`. Each input can be up to 1,000,000 characters.

Teams use the Markdown to HTML API to render user-written docs in a CMS, build newsletters from Markdown drafts, and convert HTML to Markdown for LLM and RAG pipelines. Each response also includes word, link and estimated token counts.

AI agents can call it through ApyHub MCP.

## Usage

Base URL: `https://api.eu.apyhub.com` (default region — see
`GET https://apyhub.com/api/public/regions` for the rest).

Authenticate with an ApyHub API key in the `apy-token` header.
Full docs and a live playground: https://apyhub.com/martin10291/service/convert-markdown-html
