A robust JavaScript library for converting HTML to Markdown with extensive customization options.
Turndown is a JavaScript library that converts HTML into Markdown, enabling developers to transform web content, user-generated HTML, or DOM nodes into Markdown format. It solves the problem of needing a reliable, customizable tool for generating Markdown from HTML in both Node.js and browser environments.
Developers working with content processing, static site generators, documentation tools, or applications that require HTML-to-Markdown conversion, particularly in JavaScript/Node.js ecosystems.
Developers choose Turndown for its extensive customization options, plugin support, and rule-based architecture, which allow precise control over Markdown output without complex parsing logic.
🛏 An HTML to Markdown converter written in JavaScript
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
The addRule method allows fine-grained control over conversion, enabling developers to tailor Markdown output for specific HTML elements with custom filters and replacement functions.
Turndown supports plugins via the use() method, such as turndown-plugin-gfm for GitHub Flavored Markdown features, making it easy to extend functionality without modifying core code.
It accepts various inputs including HTML strings, DOM elements, and document fragments, providing versatility for both Node.js and browser environments, as shown in the usage examples.
Options like headingStyle, codeBlockStyle, and linkStyle allow precise control over Markdown formatting, detailed in the options table for consistent output.
The README admits escaping rules are 'quite aggressive' using regular expressions, which can lead to over-escaping and unintended Markdown output, requiring manual overrides for edge cases.
To avoid complexity, Turndown relies on regex-based escaping that has performance implications, making it less suitable for high-volume or real-time processing scenarios.
Essential features like tables and strikethrough are not included by default; they require additional plugins, increasing project dependencies and setup complexity.