/api/v1/renderRender markdown API
Convert markdown into safe, sanitised HTML.
POST /api/v1/render is the Markdown Viewer API endpoint for converting markdown to HTML. Output is sanitised, supports GitHub Flavored Markdown (tables, task lists, strikethrough), and returns a deterministic { data: { html, characters } } response.
Overview
Renders a markdown document into HTML. Output is sanitised with DOMPurify — script tags, inline event handlers, and `javascript:` URLs are removed. Supports CommonMark plus GitHub Flavored Markdown (tables, task lists, strikethrough, autolinks, fenced code).
Request
Authenticate with Authorization: Bearer YOUR_API_KEY and send a JSON body containing the parameters below. Pick your language:
curl -X POST 'https://trymarkdownviewer.com/api/v1/render' \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"markdown":"# Hello world\n\nWelcome to **Markdown Viewer**."}'Body parameters
| Field | Type | Required | Description |
|---|---|---|---|
| markdown | string | required | Markdown source. Max 256 KiB. |
| sanitize | boolean | optional | Reserved. Output is always sanitised today. |
Response
Success responses are wrapped in a data field. Errors use { error: { code, message } } with an appropriate HTTP status — see the error reference.
{
"data": {
"html": "<h1 id=\"hello-world\">Hello world</h1>\n<p>Welcome to <strong>Markdown Viewer</strong>.</p>",
"characters": 78
}
}Use cases
User-generated content
Render comments, posts, and wiki pages safely. DOMPurify strips XSS payloads before the HTML leaves our server.
LLM / AI output
Display markdown responses from ChatGPT, Claude, or Gemini in your product without writing your own parser.
Documentation pipelines
Render docs at build time or on-demand. Same engine as the editor — no surprises between preview and production.
Email / report rendering
Convert markdown templates to HTML for transactional emails, dashboards, or PDF generation upstream.
Production tips
- Cache responses by content hash — identical markdown always renders to identical HTML.
- Heading ids are auto-generated and slug-safe — use them as anchors for an in-page TOC.
- Inline HTML in the input is allowed but heavily restricted by the sanitizer allowlist.
Render markdown FAQ
- Yes. Every response is sanitised with DOMPurify using a conservative allowlist — script tags, inline event handlers (onclick, onerror), javascript: URLs, and unsafe iframes are stripped before the response leaves our server.
- CommonMark plus GitHub Flavored Markdown: tables, task lists, strikethrough, autolinks, fenced code blocks. Footnotes and math are not currently supported via the API; if you need them, our editor renders them client-side.
- 256 KiB per request. If your document is larger, split it into chunks (eg. by heading or section) and render each piece separately — the renderer is deterministic, so the result is stable.
- No. The response is plain semantic HTML — h1/h2/p/ul/code/etc. — style it however you want with your own CSS or Tailwind classes. Code blocks are emitted as <pre><code class="language-xyz">.
Is the HTML output safe to inject into the DOM?
Which markdown flavour does /api/v1/render support?
What's the maximum markdown size?
Does the renderer add CSS or assume a stylesheet?
Related endpoints
Try in browser
Free tools that run the same logic locally — no API key, no upload.
Try it
Send a real request against your account in the API playground. Errors there link straight back to the error reference.