Skip to main content

Welcome to Turndown

Turndown is a JavaScript library that converts HTML to Markdown. It’s designed to be fast, flexible, and extensible, supporting both browser and Node.js environments.

Quick Start

Get up and running with Turndown in minutes

API Reference

Explore the complete API documentation

Custom Rules

Learn how to extend Turndown with custom rules

Plugins

Add functionality with the plugin system

Key Features

CommonMark Support

Full support for the CommonMark specification

Highly Configurable

Control heading styles, code blocks, delimiters, and more

Extensible Rules

Add custom rules to handle any HTML element

Plugin System

Extend functionality with reusable plugins

Cross-Platform

Works in both browser and Node.js environments

Lightweight

Minimal dependencies, maximum performance

Quick Example

Here’s a simple example of converting HTML to Markdown:
var TurndownService = require('turndown')

var turndownService = new TurndownService()
var markdown = turndownService.turndown('<h1>Hello world!</h1>')

console.log(markdown) // # Hello world!

Use Cases

Turndown is perfect for:
  • Content Migration: Convert existing HTML content to Markdown
  • Web Scraping: Extract clean Markdown from web pages
  • Rich Text Editors: Convert WYSIWYG editor output to Markdown
  • Documentation Tools: Transform HTML documentation to Markdown format
  • Email Processing: Convert HTML emails to readable Markdown

Browser and Node.js Support

Turndown works seamlessly in both environments:
var TurndownService = require('turndown')
var turndownService = new TurndownService()

Next Steps

1

Install Turndown

Install the package via npm, yarn, or pnpmGo to Installation
2

Try the Quickstart

Learn the basics with a hands-on tutorialGo to Quickstart
3

Explore the API

Dive deep into all available methods and optionsGo to API Reference

Build docs developers (and LLMs) love