HTML to Markdown Converter

HTML to Markdown Converter API

Content

Free HTML to Markdown converter with full formatting control. Transform web content for blogs, documentation, and more.

Authentication

All API requests require a valid API key passed in the Authorization header as a Bearer token.

Rate Limit

120 requests per minute

Endpoints

1 endpoint available

Overview

Convert HTML to Markdown with Turndown, the same converter the web page uses. Send an HTML string and optional formatting options, and get the Markdown back.

Options

Every key in options is optional. The defaults match the web page.

  • headingStyle: "setext" (default, underlined headings, only for levels 1 and 2) or "atx" (# headings)
  • hr: how a horizontal rule is written, up to 20 characters. Default "* * *".
  • bulletListMarker: "*" (default), "-" or "+"
  • codeBlockStyle: "indented" (default) or "fenced"
  • fence: "```" (default) or "~~~". Used when codeBlockStyle is "fenced".
  • emDelimiter: "_" (default) or "*"
  • strongDelimiter: "**" (default) or "__"
  • linkStyle: "inlined" (default) or "referenced"
  • linkReferenceStyle: "full" (default), "collapsed" or "shortcut". Used when linkStyle is "referenced".
  • preformattedCode: true to treat whitespace inside code as preformatted. Default false.

Notes

  • html is limited to 500,000 characters.
  • The HTML is parsed as text and never rendered or run. Tags Markdown has no equivalent for are dropped but their text is kept, so the text inside script and style blocks may show up in the output. Strip those blocks first if you do not want that.
  • Relative links and image paths are kept as they are.

Endpoints

POST
https://opentools.ca/api/v1/tools/html-to-markdown
Convert HTML to Markdown

Request Body

Content-Type: application/json

ParameterTypeRequiredDescription
html
string
Required
The HTML to convert, 1-500,000 characters
options
object
OptionalConversion options. All keys are optional.
options.headingStyle
string
Enum: setext, atx
OptionalHeading styleDefault: setext
options.hr
string
OptionalHorizontal rule textDefault: * * *
options.bulletListMarker
string
Enum: -, +, *
OptionalBullet list markerDefault: *
options.codeBlockStyle
string
Enum: indented, fenced
OptionalCode block styleDefault: indented
options.fence
string
Enum: ```, ~~~
OptionalFence for fenced code blocksDefault: ```
options.emDelimiter
string
Enum: _, *
OptionalEmphasis delimiterDefault: _
options.strongDelimiter
string
Enum: **, __
OptionalStrong delimiterDefault: **
options.linkStyle
string
Enum: inlined, referenced
OptionalLink styleDefault: inlined
options.linkReferenceStyle
string
Enum: full, collapsed, shortcut
OptionalReference link style, used when linkStyle is "referenced"Default: full
options.preformattedCode
boolean
OptionalTreat code whitespace as preformattedDefault: false

Response Example

{
  "success": true,
  "markdown": "Title\n=====\n\nHello **bold** and [a link](https://opentools.ca)",
  "length": 62
}

Error Codes

400
Bad Request - Missing or oversized html, invalid options, or HTML that could not be converted
401
Unauthorized - Invalid or missing API key
403
Forbidden - API key is inactive or expired, or the request IP is not allowed
429
Too Many Requests - Rate limit exceeded
500
Internal Server Error

Code Examples

curl -X POST https://opentools.ca/api/v1/tools/html-to-markdown \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "html": "<h1>Title</h1><p>Hello <strong>bold</strong> and <a href=\"https://opentools.ca\">a link</a></p>",
    "options": { "headingStyle": "atx" }
  }'

Ready to get started?

Create an API key to start using the HTML to Markdown Converter API.

Rather use it in your browser? Open the HTML to Markdown Converter