Convert HTML to clean Markdown for LLM prompts and RAG
Feeding raw HTML to a model wastes tokens on tags and attributes and buries the structure the model needs. Markdown keeps headings, links, lists and tables in a form models read well, usually at a fraction of the size.
Make the request
Send your API key in the x-api-key header. Free accounts include 1,000 calls a month.
curl -X POST https://apistack.online/api/web/html-to-markdown-converter/v1 \
-H "x-api-key: $APISTACK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"html":"<h1>Release notes</h1><p>Version <strong>2.1</strong> adds <a href=\"https://example.com/docs\">webhooks</a>.</p><ul><li>Faster sync</li><li>Bug fixes</li></ul>"}'{
"success": true,
"data": {
"markdown": "# Release notes\n\nVersion **2.1** adds [webhooks](https://example.com/docs).\n\n- Faster sync\n- Bug fixes",
"statistics": {
"originalSize": 158,
"markdownSize": 106,
"compressionRatio": 32.91,
"elementsProcessed": 14,
"linksPreserved": 1,
"tablesConverted": 0,
"headingsFound": 1
},
"validation": {
"errors": [],
"warnings": [],
"htmlValid": true,
"markdownValid": true
}
}
}Response abridged: some fields (timestamps, metadata) omitted.
In a RAG pipeline
Convert pages before chunking, then split on Markdown headings so each chunk keeps its section title. Retrieval gets noticeably better when chunks carry their headings.
Fetching the page too
This API converts HTML you send. To fetch and extract a live page in one step, use the Web Page Text Extractor API.
Give it to your AI agent
The same API is available as an MCP tool. Add APIStack to Claude, Cursor, VS Code or any MCP client:
{
"mcpServers": {
"apistack": {
"url": "https://apistack.online/api/mcp/connect",
"headers": { "x-api-key": "YOUR_API_KEY" }
}
}
}Then ask: “Convert this HTML to Markdown: <h1>Release notes</h1><p>Version 2.1 adds webhooks.</p>” See MCP setup for every client.