Convert HTML content from a web page or rich text editor into clean Markdown text.
Build a tool that exports user-written HTML blog posts or notes as Markdown files.
Add a custom rule to handle non-standard HTML tags and control exactly how they appear in Markdown output.
Use the turndown-plugin-gfm plugin to include GitHub-style tables and strikethrough formatting in the output.
Turndown is a JavaScript library that converts HTML into Markdown. You give it an HTML string (or a DOM node in a browser) and it returns the equivalent Markdown text. It works both in Node.js and directly in the browser via a script tag. The basic usage is a few lines: you create a TurndownService instance, call its turndown method with your HTML, and get a Markdown string back. For example, passing the string for an h1 heading tag returns that heading formatted as Markdown. A variety of options let you control the output style, including how headings are formatted, what character is used for bullet list items, whether code blocks are fenced or indented, and whether links are written inline or as references. The library can be extended with rules. A rule is a small JavaScript object that specifies which HTML elements to match (by tag name or a custom function) and a replacement function that returns the Markdown string for that element. This lets you handle unusual HTML tags that the library does not cover by default, or override how standard tags are converted. You can also use the keep method to tell the library to leave certain HTML elements as-is in the Markdown output rather than converting them, and the remove method to drop elements entirely. Plugins are also supported through a use method. A separate package called turndown-plugin-gfm adds support for GitHub Flavored Markdown features like tables and strikethrough, which are not part of the CommonMark standard that Turndown handles by default. Installation is through npm with a single command, or by including a script tag from a CDN. The project was previously called to-markdown and was renamed to Turndown when the repository moved.
← mixmark-io on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.