Markdown to HTML API
Render GitHub-flavored Markdown to HTML with tables and strikethrough. Output is sanitized by default to strip scripts and event handlers.
Send Markdown in the markdown field (JSON, form or query string) or as a raw text body and receive the rendered HTML in html. Rendering uses the marked parser with GitHub-flavored Markdown enabled: tables, strikethrough, autolinks and fenced code blocks are supported. Set breaks=true to turn single line breaks into <br>.
Because Markdown can contain raw HTML, the output is sanitized by default: script, style, iframe, object, embed, form and similar elements are removed, as well as on* event handlers, style attributes and javascript: / vbscript: / data:text URLs. Pass sanitize=false only when the Markdown comes from a trusted source.
The request body is limited to 1 MB and the markdown field to 2,000,000 characters.
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
markdown | body|query | string | yes | Markdown source (max 2,000,000 characters). Can also be sent as a raw text body. | |
breaks | body|query | boolean | no | false | Convert single line breaks to <br>. |
sanitize | body|query | boolean | no | true | Remove scripts, event handlers, style attributes and dangerous URLs from the output. |
Example
curl -X POST "https://apibox.io.vn/v1/markdown-to-html" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"markdown":"# Release notes\n\nVersion **2.0** adds [dark mode](https://example.com/dark).\n\n- Faster builds\n- ~~Old API~~ removed\n\n| Plan | Price |\n| --- | --- |\n| Free | $0 |"}'const res = await fetch('https://apibox.io.vn/v1/markdown-to-html', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"markdown": "# Release notes\n\nVersion **2.0** adds [dark mode](https://example.com/dark).\n\n- Faster builds\n- ~~Old API~~ removed\n\n| Plan | Price |\n| --- | --- |\n| Free | $0 |"
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"https://apibox.io.vn/v1/markdown-to-html",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"markdown": "# Release notes\n\nVersion **2.0** adds [dark mode](https://example.com/dark).\n\n- Faster builds\n- ~~Old API~~ removed\n\n| Plan | Price |\n| --- | --- |\n| Free | $0 |"},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/markdown-to-html');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"markdown":"# Release notes\\n\\nVersion **2.0** adds [dark mode](https://example.com/dark).\\n\\n- Faster builds\\n- ~~Old API~~ removed\\n\\n| Plan | Price |\\n| --- | --- |\\n| Free | $0 |"}',
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));Response
{
"html": "<h1>Release notes</h1>\n<p>Version <strong>2.0</strong> adds <a href=\"https://example.com/dark\">dark mode</a>.</p>\n<ul>\n<li>Faster builds</li>\n<li><del>Old API</del> removed</li>\n</ul>\n<table>\n<thead>\n<tr>\n<th>Plan</th>\n<th>Price</th>\n</tr>\n</thead>\n<tbody><tr>\n<td>Free</td>\n<td>$0</td>\n</tr>\n</tbody></table>\n"
}
Use cases
- Render README or documentation files on your own website
- Display user comments written in Markdown without XSS risk
- Generate HTML email bodies or newsletters from Markdown drafts
- Preview Markdown in a CMS or static site generator pipeline
FAQ
Is the generated HTML safe to insert into a page?
By default yes for common attacks: scripts, iframes, forms, event handlers, style attributes and javascript: links are removed. Disable with sanitize=false only for trusted input.
Does it support GitHub-flavored Markdown tables?
Yes. GFM is enabled, so pipe tables, ~~strikethrough~~ and autolinks are rendered.
How do I keep single line breaks?
Set breaks=true. Each newline inside a paragraph then becomes a <br> tag, like on GitHub comments.
Related APIs
HTML to Markdown
Convert HTML or any web page URL into clean GitHub-flavored Markdown, with tables, optional article extraction and absolute links.
<✓>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.