Text

Markdown to HTML

0calls
1 credits / call

Call this endpoint directly to convert Markdown text to styled HTML. It's not only suitable for dynamic injection in programs, but also for direct preview during development.

How to Use and Preview

  • Default Mode: Returns HTML fragment in JSON: When format is not passed, the endpoint returns JSON. You just need to read data.html from the response and assign it to the frontend container, e.g., element.innerHTML = data.html, Vue's v-html, or React with dangerouslySetInnerHTML.
  • Preview Mode: Directly returns complete HTML webpage: If you want to open the result directly in a browser, or save the response as an independent .html file, pass format="html". In this mode, the endpoint will directly return complete webpage source code with <!DOCTYPE html><html>....

Overview

  • Beautiful typography built-in, no need to write CSS manually: The returned results already have built-in styles, titles, quotes, tables, task lists and code blocks can be displayed directly.
  • Supports rich layout elements: In addition to standard Markdown, this endpoint can also correctly handle common GFM syntax, such as tables, task lists and code blocks with language tags.
  • Secure handling of user content: Security mode is enabled by default, automatically filtering risky scripts in raw HTML. If the content source is absolutely trusted and you really need to keep the original HTML, you can set sanitize to false.

Request body

Request body uses application/json. text is required; format and sanitize are optional.

text
stringrequired

Raw Markdown string, maximum size not exceeding 1MB.

format
stringoptional

Response format. Pass json to return JSON-wrapped HTML fragment; pass html to directly return text/html, and response content will automatically include complete webpage structure, suitable for browser preview or direct save as webpage file. Default is json.

sanitize
booleanoptional

Whether to enable security mode, filtering out risky scripts in user input. Default is true.

Response

200 / OK

Conversion successful. Whether JSON or plain HTML is returned depends on the format parameter.

Format 1application/json
JSON
Format 2text/html
HTML

400 / Bad Request

Request parameter error. May be request body format error, text is empty, or format value is invalid.

Format 1Request body format error
JSON
Format 2Missing Markdown text
JSON
Format 3Response format error
JSON

413 /

Markdown text exceeds current size limit.

JSON

500 / Internal Server Error

Error occurred during conversion, please try again later.

JSON

503 / Service Unavailable

Service temporarily unavailable.

JSON