Markdown to HTML API: render GitHub-style Markdown safely
GitHub's REST API has a POST /markdown endpoint that renders Markdown to HTML, but unauthenticated calls share a limit of 60 requests an hour per IP. In your own code, libraries like marked, markdown-it or Python-Markdown do it for free; the hard part is sanitising user input so it can't inject scripts. Our Markdown to HTML API renders GitHub-style Markdown and makes the output safe for $0.002 per call.
Try it free Markdown to HTML API — safe output, GFM tables, $0.002 · $0.002 / call
Your options
| Option | Cost | Watch out for |
|---|---|---|
| GitHub POST /markdown | Free with limits | 60 an hour without a token, 5,000 with one; GitHub-specific output |
| marked or markdown-it (JavaScript) | Free | Neither sanitises by default; add DOMPurify |
| Python-Markdown or mistune | Free | Sanitise with a library such as bleach or nh3 |
| Markdown to HTML (iamai.markets) | $0.002 per call | No syntax highlighting or custom extensions |
Why sanitising matters
Markdown allows raw HTML, and links can use the javascript: scheme. If users write the Markdown, a renderer without sanitising will pass a script tag or a javascript: link straight into your page. That's a cross-site scripting hole, and it's the most common mistake with Markdown on websites.
<!-- this Markdown, rendered without sanitising, runs code -->
[click me](javascript:alert(document.cookie))
<img src=x onerror="alert(1)">
What our API returns
- html: GitHub-flavoured Markdown rendered with the marked library, including tables and strikethrough.
- Raw HTML in the input is escaped and shown as text, never run.
- Links and images using javascript:, data: or other non-web schemes are removed; http, https, mailto, tel and relative links stay.
- text: a plain-text version, and headings: the outline with level and text.
- Counts of escaped HTML blocks and removed links, so you can warn the author.
curl -i -X POST https://iamai.markets/api/x402/services/WI0dfbtNv8kv \
-H "Content-Type: application/json" \
-d '{"markdown": "# Price list\n\nSee [the docs](https://iamai.markets/agents).\n\n| Item | Price |\n|---|---|\n| Pen | $2 |"}'
# result: html, text, headings, words, raw_html_escaped, unsafe_links_removed
Command line, for build scripts
If you need Markdown to HTML in a build, pandoc (pandoc README.md -o README.html) or the marked CLI (npx marked -i README.md -o README.html) are free and fast. They trust their input, which is fine for your own files.
Limits
Up to 200,000 characters per call. If you need raw HTML to pass through on purpose, such as your own embeds, this API is the wrong tool: it always escapes it. Paid per call with x402 in USDC on Base; 5 free tries a day on the listing page.
The product
Questions
Does it add ids to headings?
Don't count on it. Use the headings list it returns to build your own table of contents.
Can I render LLM output with it?
Yes, that's a good use: model output is untrusted text, and the API makes it safe to show on a page.
What is the difference between HTML and Markdown?
Markdown is a short way of writing formatting (# for headings, ** for bold) that tools turn into HTML, the language browsers display.
Related
Updated 2026-12-02
