HTML to Markdown

The /html_to_md endpoint converts the given HTML code to Markdown code. It is highly customizable via the options parameter in the request body.

Method: POST

To make a request, send the required parameters, to the /html_to_md endpoint, with the authorization headers, via the POST method.

Parameters

This endpoint accepts only two parameters, i.e. html and options object.

  • html is the HTML which is to be converted to Markdown.
  • options contains the customization options. These are the supported customization options:
    • heading_style is the style in which the heading will be converted. Accepted values are atx or setext Default value is atx.
    • hr is the characters which would be used for horizontal rules. Default is: ***
    • code_block_style is the style for the code blocks. Possible values are fenced and indented. The default is fenced
    • em_delimeter is the character which would be used to surround the emphasized or italic text. Its default values is: *
    • strong_delimeter is the character, that will surround the strong or bold text. Its default value is **
    • fence refers to the characters used for opening and closing the fence. Supported values are ``` or ~~~. Its default value is ```
    • link_style is the style in which the links will be kept. Possible values are inlined or referenced. Default value is inlined.
    • link_reference_style defines the link format in the output Markdown. Possible values are full, collapsed or shortcut. The default value is full.
    • preformatted_code is a boolean values which determines whether the code block is preformatted, and if it is, it keeps the indentation as it is. Default value is true
    • bullet_list_marker is the character used to mark bullet lists in the output Markdown. Default value is *

Responses

The success response, looks like this, where markdown in data object contains the converted output:

{
  "status": "success",
  "data": {
    "source_html": "\n\t\t<h1>This is a heading</h1>\n\t\t<p>This is a paragraph with some\n\t\t<em>emphasized</em> and <strong>strong</strong> text.\n\t",
    "markdown": "# This is a heading\n\nThis is a paragraph with some *emphasized* and **strong** text.",
    "options_applied": {
      "heading_style": "atx"
    }
  },
  "message": "HTML to Markdown conversion was successful."
}

And if some error occurs, like not providing the html data in the request body, the response is similar as all other endpoints:

{
  "status": "error",
  "error": {
    "code": "INVALID_INPUT",
    "message": "'html' is required and must be a non-empty string.",
    "details": "Ensure the request body includes a valid 'html' field of type string."
  }
}