MarkDown TurnDown icon

MarkDown TurnDown

Node to use in n8n that allows you to convert HTML to MarkDown using one of the most famous JS libraries that perform this conversion to Turndown | PT-BR: Nó para usar em n8n que permite converter HTML para MarkDown usando uma das bibliotecas JS mais famosas que realizam essa conversão, Turndown

Overview

This node converts text between HTML and Markdown formats. It supports two main operations: converting HTML to Markdown and converting Markdown to HTML. This is useful in workflows where content needs to be transformed for different platforms or editors that support only one of these markup languages.

Common scenarios include:

  • Converting HTML content from web pages or rich text editors into Markdown for documentation or version control.
  • Transforming Markdown notes or files into HTML for web display or email formatting.
  • Using GitHub Flavored Markdown (GFM) syntax when converting HTML to Markdown to maintain compatibility with GitHub's extended Markdown features.

Example:

  • Inputting an HTML snippet and getting a Markdown version to store in a markdown file.
  • Taking a Markdown blog post and converting it to HTML for publishing on a website.

Properties

Name Meaning
Input The input string to be transformed. Can be HTML or Markdown depending on the operation.
Output Key The key name under which the output result will be stored in the JSON output object.
Use GFM Plugin Boolean flag to enable GitHub Flavored Markdown plugin when converting HTML to Markdown.

Output

The node outputs JSON data where the transformed text is stored under the user-defined key (default "data"). For example, if the output key is "data", the output JSON will contain:

{
  "data": "<converted text>"
}
  • When converting HTML to Markdown, the output is a Markdown string.
  • When converting Markdown to HTML, the output is an HTML string.

No binary data output is produced by this node.

Dependencies

  • Uses the turndown library to convert HTML to Markdown.
  • Optionally uses the joplin-turndown-plugin-gfm plugin to support GitHub Flavored Markdown during HTML to Markdown conversion.
  • Uses the marked library to parse Markdown into HTML.

No external API keys or credentials are required. All processing is done locally within the node.

Troubleshooting

  • Unknown Operation Error: If an unsupported operation is selected, the node throws an error indicating the operation is not known. Ensure the operation parameter is either "htmlToMarkdown" or "markdownToHtml".
  • Invalid Input Format: Providing input that does not match the expected format for the chosen operation (e.g., passing Markdown when converting HTML to Markdown) may produce unexpected results or errors.
  • Plugin Usage: Enabling the GFM plugin only affects HTML to Markdown conversion. It has no effect on Markdown to HTML conversion.
  • Large Inputs: Very large HTML or Markdown inputs might cause performance issues or timeouts depending on the environment.

Links and References

Discussion