Skip to main content

Installation

Turndown can be installed via npm for Node.js projects or loaded directly in the browser via CDN. Choose the installation method that best fits your project.

Package Managers

Install Turndown using your preferred package manager:
The package includes multiple build formats to support different environments:
  • CommonJS: lib/turndown.cjs.js (main entry point)
  • ES Module: lib/turndown.es.js
  • UMD: lib/turndown.umd.js (Node.js) and lib/turndown.browser.umd.js (browser)
  • IIFE: dist/turndown.js (browser global)

Browser Installation

CDN (unpkg)

For quick browser usage, load Turndown directly from the unpkg CDN:
The CDN script creates a global TurndownService constructor that you can use immediately.

RequireJS/AMD

If you’re using RequireJS or another AMD loader, use the UMD build:

Build from Source

To build Turndown from source:
1

Clone the repository

2

Install dependencies

3

Build the project

This generates all build formats:
  • CommonJS builds (CJS and browser CJS)
  • ES module builds (ES and browser ES)
  • UMD builds (Node.js and browser)
  • IIFE build for browsers
The built files will be available in the lib/ and dist/ directories.

Verify Installation

Node.js

After installing via npm, verify that Turndown is working:
If you see the Markdown output, Turndown is installed correctly!

Browser

In the browser, check that the global TurndownService constructor is available:

Package Configuration

The package.json specifies browser-specific builds that exclude Node.js dependencies:
This ensures that when bundling for the browser, the @mixmark-io/domino dependency (used for server-side HTML parsing) is excluded and the appropriate browser builds are used instead.

Next Steps

Quickstart

Follow a step-by-step tutorial to start converting HTML to Markdown

Node.js Usage

Learn how to use Turndown in Node.js applications

Browser Usage

Explore browser-specific usage patterns

API Reference

Explore the complete API documentation