turndown

Convert HTML into clean, customizable Markdown in Node.js and the browser.

Library
npm
v7.2.4
11,391stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
54/100Fair
Development Activity24
Maintenance20
Community72
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
85/100Excellent
Architecture85
Code Quality82
Innovation84
Learning Curve88

Turndown is a small, dependency-light JavaScript library that converts HTML into Markdown. It accepts either an HTML string or a DOM node and produces CommonMark-compatible output, running the same code in Node.js (via domino) and directly in the browser.

Its real strength is extensibility: a rule engine lets you add custom conversion rules, keep or remove specific elements, override Markdown escaping, and layer in plugins such as GitHub Flavored Markdown support. This makes it a common building block for content pipelines, rich-text-to-Markdown editors, scrapers, and note-taking tools.

What You Get

  • A TurndownService class that converts HTML strings or DOM nodes to CommonMark-style Markdown
  • Configurable options for heading style, bullet markers, code-block fencing, emphasis and link styles
  • An extensible rule system (addRule, keep, remove) plus a plugin API (use) for behaviors like GFM tables and strikethrough
  • Isomorphic builds (CJS, ESM, UMD, IIFE) that run in Node.js and the browser

Common Use Cases

  • Converting WYSIWYG/rich-text editor HTML into Markdown for storage
  • Turning scraped or fetched web pages into Markdown for LLM ingestion or archival
  • Migrating CMS or blog content from HTML to Markdown files
  • Building note-taking and clipping tools that save web content as Markdown

Under The Hood

Architecture

Turndown centers on the TurndownService constructor in src/turndown.js, which merges user options over CommonMark defaults and builds a Rules collection (src/rules.js). The turndown() entry point wraps input in a RootNode (src/root-node.js), then recursively reduces the DOM: process() walks childNodes, wrapping each in a Node (src/node.js) that computes block/blank/flanking-whitespace metadata, and replacementForNode() finds the first matching rule and applies its replacement function. A join() helper reconciles blank-line spacing between fragments, and postProcess() runs rule append hooks and trims the result. In Node.js the HTML is parsed via @mixmark-io/domino (src/html-parser.js); in the browser the native DOMParser is used instead.

Tech Stack

Pure JavaScript authored as ES modules with a single runtime dependency, @mixmark-io/domino (^2.2.0), for server-side DOM parsing. Rollup bundles four output formats (CJS, ESM, UMD, IIFE) plus browser-specific variants via config files under config/, with Babel transforms for block-scoping and shorthand properties. Standard (standardjs) enforces style. Engines require Node >=18. There is no TypeScript in the source, though the library is widely paired with community type definitions.

Code Quality

The codebase is compact and readable, with each concern isolated in its own small module (rules, node, root-node, collapse-whitespace, utilities). Public methods carry JSDoc, and there is a real test suite: test/turndown-test.js drives fixture-based conversions through turndown-attendant plus explicit edge cases (null/undefined input, malformed documents, rule precedence, chaining return values), and test/internals-test.js exercises internal helpers. Notable care shows in details like the hand-rolled trimTrailingNewlines to avoid a regex backtracking bottleneck (issue #370). Style is enforced by standard in the test script.

API Design

The developer experience is excellent for its scope: new TurndownService().turndown(html) is the entire happy path, and every extension point (addRule, keep, remove, use, escape override, and constructor options) returns the instance for chaining and is documented in the README with copy-paste examples. Option names read naturally (headingStyle, bulletListMarker, codeBlockStyle), and the rule filter/replacement contract is small and consistent, making custom rules and plugins straightforward to write.

Used by 36 apps in this directory

TypeScript
95%
Apache 2.0

AionUi

AI Agents · Productivity

32,102

Free, open-source Cowork desktop app that unifies Claude Code, Codex, Gemini CLI, and 20+ AI agents into a single platform with multi-agent teams, 24/7 cron automation, and zero-config built-in agent.

View details
88
Repo Health
76
Technical
66
Dependency
Built with
TypeScript95%
Updated today
TypeScript
72%
AGPL 3.0

APITable

Low Code Platforms · Databases

15,526

API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.

View details
53
Repo Health
77
Technical
60
Dependency
Built with
TypeScript72%
Java22%
Updated 9 months ago
JavaScript
95%
MIT

AnythingLLM

Developer Tools · Automation · AI Assistants

64,914

The all-in-one AI platform for private document chat, no-code agents, and local LLMs with zero setup friction.

View details
91
Repo Health
78
Technical
68
Dependency
Built with
JavaScript95%
Updated today
TypeScript
100%
AGPL 3.0

BaseBuddy

CMS

7

A self-hosted content editor for existing Postgres or Supabase schemas — maps the tables you already have into a WordPress-like TipTap editor instead of requiring you to reshape your database around a CMS.

View details
46
Repo Health
64
Technical
76
Dependency
Built with
TypeScript100%
Updated 1 weeks ago
TypeScript
100%
MIT

Botpress

AI Assistants · AI Development · Customer Support

14,872

The open-source hub for building and deploying LLM-powered AI agents with TypeScript-first tooling, 40+ integrations, and a revolutionary code-execution agent framework.

View details
95
Repo Health
82
Technical
66
Dependency
Built with
TypeScript100%
Updated yesterday
TypeScript
96%
Other

Cal.diy

Scheduling

47,796

The 100% MIT-licensed, community-driven scheduling platform — self-host your own booking infrastructure with no enterprise strings attached.

View details
93
Repo Health
86
Technical
66
Dependency
Built with
TypeScript96%
Updated 1 weeks ago
TypeScript
99%
AGPL 3.0

Cherry Studio

AI Assistants

50,753

All-in-one AI desktop client with 300+ assistants and multi-model support

View details
88
Repo Health
84
Technical
71
Dependency
Built with
TypeScript99%
Updated today
TypeScript
97%
Apache 2.0

Cline

AI Code Assistants

66,453

An open-source AI coding agent that lives in your editor and terminal — reads and edits your codebase, runs commands, browses the web, and requires human approval for every action by default.

View details
90
Repo Health
74
Technical
67
Dependency
Built with
TypeScript97%
Updated today
Swift
64%
GPL 3.0

cmux

Developer Tools · AI Development

26,221

A native, Ghostty-based macOS terminal with vertical tabs, agent-aware notifications, and a scriptable browser built for running many parallel AI coding agent sessions instead of juggling tmux panes.

View details
84
Repo Health
81
Technical
72
Dependency
Built with
Swift64%
Rust14%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search