Disclosure: I work on APIBox, the API used in this guide. The first draft was written with AI assistance; I tested the code and edited it.
Markdown has quietly become the exchange format of the AI era. LLMs read it well, it costs far fewer tokens than raw HTML, note apps like Obsidian store it natively, and every static site generator speaks it.
The web, however, still ships HTML: navigation bars, cookie banners, inline scripts, tracking pixels and a dozen nested <div> s around three paragraphs of actual content.
This guide shows how to use the APIBox /v1/html-to-markdown endpoint to turn HTML strings or live URLs into clean Markdown, and how to wire it into four common jobs: LLM prompts, scrapers, content migration and HTML email.
You send either an html string or a public url. You get back Markdown plus a little metadata:
script, style, iframe, svg and canvas elements are dropped.href and src values are resolved against the fetched URL or your base_url. readability=true runs Mozilla Readability (the engine behind Firefox Reader View) to keep only the main article and return an excerpt. words and characters let you budget prompt size before you send anything to a model.heading_style (atx / setext), bullet (-, *, +), code_block_style (fenced / indented), link_style (inlined / referenced), keep_links, keep_images. robots.txt.
Create a free APIBox account (Free plan: 1,000 requests per month, 30 per minute, no card) and generate an API key:
export APIBOX_KEY="your_key_here"
The key can go in Authorization: Bearer, an x-api-key header, or an api_key query parameter. Prefer a header so keys don't end up in logs.
curl -s https://apibox.io.vn/v1/html-to-markdown \
-H "Authorization: Bearer $APIBOX_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"
}'
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
}
Notice three things: the relative /docs link became https://example.com/docs thanks to base_url, the HTML table became a real Markdown table, and title is empty because the fragment has no <title> element.
You can also skip JSON entirely and POST raw HTML with Content-Type: text/html:
curl -s https://apibox.io.vn/v1/html-to-markdown \
-H "Authorization: Bearer $APIBOX_KEY" \
-H "Content-Type: text/html" \
--data-binary '<h2>Raw</h2><p>Hello <em>world</em></p>'
{"title":"","markdown":"## Raw\n\nHello _world_","characters":21,"words":4}
Feeding a whole page's HTML to a model wastes tokens on markup and boilerplate. Fetch it as Markdown with readability=true, check the size, then build the prompt:
const KEY = process.env.APIBOX_KEY;
async function pageAsMarkdown(url) {
const r = await fetch('https://apibox.io.vn/v1/html-to-markdown', {
method: 'POST',
headers: { Authorization: `Bearer ${KEY}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ url, readability: true, keep_images: false }),
});
if (!r.ok) throw new Error(`html-to-markdown ${r.status}: ${await r.text()}`);
return r.json(); // { title, markdown, excerpt, words, characters }
}
const page = await pageAsMarkdown('https://en.wikipedia.org/wiki/Markdown');
// Rough budget check before calling your model
if (page.words > 6000) console.warn(`Long page (${page.words} words) – consider chunking`);
const prompt = `Summarise the article below in 5 bullet points.\n\n# ${page.title}\n\n${page.markdown}`;
console.log(prompt.slice(0, 500));
What came back on 2026-11-25 (first lines of the prompt, then the metadata):
Summarise the article below in 5 bullet points.
From Wikipedia, the free encyclopedia
| Markdown |
| --- |
| [](https://en.wikipedia.org/wiki/File:Markdown-mark.svg) |
| [Filename extensions](https://en.wikipedia.org/wiki/Filename_extension "Filename extension") | `.md`, `.markdown`[\[1\]](https://en.wikipedia.org/wiki/Markdown#cite_note-df-2022-1)… (truncated)
{ "title": "Markdown", "excerpt": "From Wikipedia, the free encyclopedia", "words": 3360, "characters": 47587 }
About 47,000 characters for a long encyclopedia article, well under the 6,000-word warning, so it can go to a model in one piece. Two things to notice: Readability kept the infobox as a Markdown table, and keep_images: false removed the logo image but left an empty [](…) link where the image had been wrapped in a link. If empty links bother your model, strip [](...) with a one-line regex.
Why these options:
readability: true strips nav, footers and sidebars, which are pure noise for a summariser.keep_images: false drops image syntax the model can't see anyway.
If you are building retrieval (RAG), split on Markdown headings: ## sections make natural chunks that keep context together.
Many scrapers end with a messy "extract text" step. Markdown keeps structure (headings, lists, tables, links) that plain text loses, while staying easy to diff and store:
import os, requests
KEY = os.environ["APIBOX_KEY"]
def to_markdown(url):
r = requests.post(
"https://apibox.io.vn/v1/html-to-markdown",
json={"url": url, "readability": True, "link_style": "referenced"},
headers={"Authorization": f"Bearer {KEY}"},
timeout=30,
)
r.raise_for_status()
return r.json()
doc = to_markdown("https://keepachangelog.com/en/1.1.0/")
with open("changelog.md", "w", encoding="utf-8") as f:
f.write(doc["markdown"])
print(doc["words"], "words saved")
Output:
1142 words saved
And the start and end of changelog.md:
### [][1]What is a changelog?
A changelog is a file which contains a curated, chronologically ordered list of notable changes for each version of a project.
### [][2]Why keep a changelog?
… (truncated)
The [][1] before each heading is the page's own empty anchor link (<a href="#what">), kept as a reference.
link_style: "referenced" moves URLs to the bottom as [1]: https://... references, which keeps long documents readable and makes link changes easy to spot in a git diff.
Stay on the Free plan's 30 requests/minute by adding a short sleep between URLs, and store results so you don't re-fetch unchanged pages.
Moving from WordPress or a legacy CMS to a static site generator usually means exporting HTML bodies from a database. Send each body with base_url set to the old site so images and internal links stay absolute:
curl -s https://apibox.io.vn/v1/html-to-markdown \
-H "Authorization: Bearer $APIBOX_KEY" \
-H "Content-Type: application/json" \
-d '{"html": "<p>See <a href=\"/2019/05/old-post\">my old post</a>.</p><img src=\"/wp-content/uploads/a.png\">", "base_url": "https://old-blog.example", "heading_style": "atx", "bullet": "-"}'
{
"title": "",
"markdown": "See [my old post](https://old-blog.example/2019/05/old-post).\n\n",
"characters": 117,
"words": 5
}
Both the link and the image now point at the old domain. Keep it that way while migrating, then search-and-replace the domain once the new site is up. Notice also that the empty alt on the image gave ![]. That is a good moment to fill in missing alt text.
Pin heading_style, bullet and code_block_style explicitly so every converted file follows the same style, then run your usual Markdown linter once over the output.
The same endpoint works for HTML produced by email clients and WYSIWYG editors. A common pattern: store user content as Markdown (easy to diff, search and render anywhere), and convert editor output on save. Pair it with the companion /v1/markdown-to-html endpoint, which sanitises output by default, when you need to render it back.
Converting HTML to Markdown is a solved problem in most languages: Turndown in JavaScript, markdownify or html2text in Python, and full open-source services you can self-host. If you already run a Node or Python backend and only convert HTML you control, a library is the simplest choice.
An API makes more sense when:
There are other hosted HTML-to-Markdown services too; pick the one whose limits and pricing fit your workload.
Can I convert a page by URL instead of pasting HTML?
Yes. Send url instead of html. If both are present, url wins (we checked: sending html: "<p>X</p>" together with url: "https://example.com" returned the Example Domain text).
Are HTML tables converted?
Yes. Tables, strikethrough and task lists follow GitHub-flavored Markdown rules.
How do I remove links or images?
keep_links=false keeps only the link text; keep_images=false drops img, picture and figure elements.
Does it render JavaScript?
No. It converts the HTML the server returns. Render client-side apps yourself first, then send the HTML.
Is there a request size limit?
HTML up to 5 MB, request body up to 6 MB, and fetched pages are read up to 5 MB.
Free plan: 1,000 requests per month, no credit card.
Full parameter reference: HTML to Markdown API docs. Try it without code: online HTML to Markdown converter.