Description
Turndown is an HTML to Markdown converter written in JavaScript. You give it HTML, either as a string or as DOM nodes, and it returns Markdown, so you can take web content or rich-text editor output and store it in a Markdown format. It runs in Node.js and in web browsers, and it can be installed from npm or loaded in the browser, with UMD builds for RequireJS users. The constructor accepts options that control the output: heading style, using setext or ATX headings, the horizontal rule, bullet list marker, code block style, fence characters, emphasis and strong delimiters, link style, link reference style and whether preformatted code is kept. Advanced options let you supply replacement functions for blank elements, elements to keep as HTML, and a default replacement. The library's methods include addRule to add a conversion rule for a particular kind of element, and it has special rules for elements that have no Markdown equivalent. The project's README records that the older name to-markdown was renamed to Turndown and that the repository moved to the mixmark-io organisation, with a migration guide. There is also an online demo where you can see the conversion. Turndown is useful for importing content from HTML sources, migrating a site to a Markdown-based system, or building an editor that saves Markdown. The project is hosted on GitHub.…
Highlights
- HTML to Markdown conversion
- Works in Node.js and browsers
- Options for headings, lists, code and links
- Custom conversion rules with addRule
- Accepts DOM nodes as input
- UMD builds
Ratings & Reviews
No ratings yet
Be the first to rate Turndown.
People also visit
Turndown FAQ
What does Turndown do?
It converts HTML into Markdown in JavaScript, in Node.js or in the browser.
How do I install it?
From npm for Node.js, or as a browser script, with UMD builds for RequireJS.
Can I change the output style?
Yes. Options cover heading style, list markers, code blocks, emphasis, strong text and link style.
Can I add my own rules?
Yes. The addRule method adds a conversion rule for a kind of element.
Does it accept DOM nodes?
Yes. Element, document and document fragment nodes are accepted as input.
Was the project renamed?
Yes. The README says to-markdown was renamed to Turndown, and gives a migration guide.
What are the best Turndown alternatives?
Popular alternatives to Turndown include Pdf2md, mdto.page and Typo. See all Turndown alternatives




