Skip to main content

Endpoint

POST https://api.bunny.build/api/v1/markdown-to-html

Authentication

HeaderRequiredValue
X-API-KeyYesYour API key (bun_...)
Content-TypeYesapplication/json

Overview

Convert Markdown source into sanitized HTML ready for rendering in browsers or email clients. Supports GitHub Flavored Markdown (GFM), tables, task lists, fenced code blocks with syntax highlighting, and strikethrough. Output is sanitized to prevent XSS.

Use cases

  • Render user-generated Markdown content safely in web apps
  • Convert README or documentation files to HTML for display
  • Process blog post drafts written in Markdown
  • Generate HTML emails from Markdown templates

Details

Parsing follows the CommonMark specification with GFM extensions. HTML in the input is sanitized. Code blocks are wrapped in <pre><code> tags with a language class for CSS-based highlighting.

Request body

FieldTypeRequiredDescription
markdownstringYesMarkdown source text to convert

Example

{
  "markdown": "# Hello\n\nThis is **bold** and _italic_ text.\n\n```js\nconsole.log('hi');\n```"
}

Response

200 OK

FieldTypeDescription
htmlstringRendered, sanitized HTML
word_countintegerNumber of words in the input Markdown source
reading_time_minutesintegerEstimated reading time in minutes (minimum 1, based on 200 wpm)
charsintegerCharacter count of the input Markdown source
Example
{
  "html": "<h1>Hello</h1>\n<p>This is <strong>bold</strong> and <em>italic</em> text.</p>\n<pre><code class=\"language-js\">console.log('hi');\n</code></pre>",
  "word_count": 12,
  "reading_time_minutes": 1,
  "chars": 74
}

401 Unauthorized

{
  "detail": "Missing API key. Include X-API-Key header."
}

402 Payment Required

{
  "detail": "Monthly quota exceeded. Upgrade your plan."
}

422 Unprocessable Entity

{
  "detail": "Missing required field: markdown"
}

429 Too Many Requests

{
  "detail": "Rate limit exceeded. Try again in 60 seconds."
}

cURL example

curl -X POST https://api.bunny.build/api/v1/markdown-to-html \
  -H "X-API-Key: bun_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"markdown": "# Hello\n\nThis is **bold** text."}'