HTML to Markdown API
Convert HTML or any web page URL into clean GitHub-flavored Markdown, with tables, optional article extraction and absolute links.
Send an HTML string (JSON or form field html, or a raw text/html body) or a public url, and get clean Markdown back together with the page title and word and character counts. Scripts, styles, iframes, SVG and canvas elements are dropped, and GitHub-flavored extensions such as tables, strikethrough and task lists are converted.
Set readability=true to keep only the main article of a page (Mozilla Readability, the engine behind Firefox Reader View): navigation, footers and sidebars are removed and an excerpt is returned. Relative links and image sources are made absolute using the fetched URL or base_url. Output style is configurable: heading_style (atx or setext), bullet (-, * or +), code_block_style (fenced or indented), link_style (inlined or referenced), and keep_links / keep_images to strip links or images.
Limits: HTML up to 5 MB (request body up to 6 MB); pages fetched from a URL are read up to 5 MB, with a 10 second timeout and at most 8 redirects. Only public http/https hosts are allowed.
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
html | body|query | string | no | HTML to convert (max 5 MB). Can also be sent as a raw text/html body. Required unless url is given. | |
url | body|query | string | no | Public http/https URL of a page to fetch and convert (takes precedence over html). | |
base_url | body|query | string | no | Base URL used to make relative links and image sources absolute when sending html. | |
readability | body|query | boolean | no | false | Extract only the main article (Readability) and return an excerpt. Alias: article. |
keep_links | body|query | boolean | no | true | Keep links; when false only the link text is kept. |
keep_images | body|query | boolean | no | true | Keep images; when false img, picture and figure elements are removed. |
heading_style | body|query | string | no | atx | Heading style: atx (# Title) or setext (underlined). |
bullet | body|query | string | no | - | Bullet list marker: -, * or +. |
code_block_style | body|query | string | no | fenced | Code blocks: fenced (``) or indented`. |
link_style | body|query | string | no | inlined | Links: inlined [text](url) or referenced [text][1]. |
Example
curl -X POST "https://apibox.io.vn/v1/html-to-markdown" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"html":"<h1>Getting started</h1><p>APIBox turns <strong>HTML</strong> into clean <a href=\"/docs\">Markdown</a>.</p><ul><li>Fast</li><li>Simple</li></ul><table><tr><th>Plan</th><th>Requests</th></tr><tr><td>Free</td><td>1,000</td></tr></table>","base_url":"https://example.com"}'const res = await fetch('https://apibox.io.vn/v1/html-to-markdown', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"html": "<h1>Getting started</h1><p>APIBox turns <strong>HTML</strong> into clean <a href=\"/docs\">Markdown</a>.</p><ul><li>Fast</li><li>Simple</li></ul><table><tr><th>Plan</th><th>Requests</th></tr><tr><td>Free</td><td>1,000</td></tr></table>",
"base_url": "https://example.com"
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"https://apibox.io.vn/v1/html-to-markdown",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"html": "<h1>Getting started</h1><p>APIBox turns <strong>HTML</strong> into clean <a href=\"/docs\">Markdown</a>.</p><ul><li>Fast</li><li>Simple</li></ul><table><tr><th>Plan</th><th>Requests</th></tr><tr><td>Free</td><td>1,000</td></tr></table>", "base_url": "https://example.com"},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/html-to-markdown');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"html":"<h1>Getting started</h1><p>APIBox turns <strong>HTML</strong> into clean <a href=\\"/docs\\">Markdown</a>.</p><ul><li>Fast</li><li>Simple</li></ul><table><tr><th>Plan</th><th>Requests</th></tr><tr><td>Free</td><td>1,000</td></tr></table>","base_url":"https://example.com"}',
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));Response
{
"title": "",
"markdown": "# Getting started\n\nAPIBox turns **HTML** into clean [Markdown](https://example.com/docs).\n\n- Fast\n- Simple\n\n| Plan | Requests |\n| --- | --- |\n| Free | 1,000 |",
"characters": 162,
"words": 28
}
Use cases
- Feed web pages to an LLM or RAG pipeline as compact Markdown
- Migrate a blog or CMS content from HTML to Markdown files
- Save articles in reader mode for notes apps such as Obsidian
- Convert HTML emails or rich-text editor output to Markdown
FAQ
Can I convert a web page by URL instead of pasting HTML?
Yes. Send url instead of html; the API fetches the page (up to 5 MB) and converts it. Add readability=true to keep only the main article content.
Are HTML tables converted to Markdown tables?
Yes. Tables, strikethrough and task lists are converted using GitHub-flavored Markdown rules.
How do I remove links or images from the Markdown?
Set keep_links=false to keep only the link text, and keep_images=false to drop img, picture and figure elements.
Related APIs
Markdown to HTML
Render GitHub-flavored Markdown to HTML with tables and strikethrough. Output is sanitized by default to strip scripts and event handlers.
<✓>HTML Sanitizer
Strip scripts, iframes, forms, event handlers, inline styles and javascript: links from untrusted HTML before you display it.
TtHTML to Text
Strip tags from HTML or a web page URL and get readable plain text with line breaks preserved, plus word and character counts.