html-to-text

Advanced HTML to plain text converter with word wrapping, tables, and customizable selectors

Library
npm
v10.0.0
1,765stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
46/100Fair
Development Activity12
Maintenance0
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
Innovation88
Learning Curve75

html-to-text is a battle-tested Node.js library that parses HTML documents and renders them as clean, readable plain text. It handles the messy realities of real-world markup — inline and block-level tags, tables with colspans and rowspans, links with their hrefs, Unicode content, and word wrapping — so you never have to strip tags with brittle regular expressions again.

Beyond simple tag stripping, it exposes a stylesheet-like selector system that lets you decide exactly how each element is formatted, skipped, or transformed. With over 11 million weekly downloads, it is the de-facto standard for generating plain-text email bodies, previews, search indexes, and text snapshots from HTML.

What You Get

  • A simple convert / htmlToText function plus a compile factory for reusing options across many documents at high throughput
  • A stylesheet-like selector system to format, skip, or customize the rendering of any HTML element
  • Built-in formatters for links, images, tables, ordered and unordered lists, headings, blockquotes, and horizontal rules
  • Configurable word wrapping, long-word splitting, whitespace handling, and entity decoding
  • Dual CommonJS and ES module builds with bundled TypeScript typedefs

Common Use Cases

  • Generating plain-text alternatives for HTML emails so messages render in text-only clients
  • Producing readable previews, excerpts, or notification snippets from stored HTML content
  • Feeding clean text into full-text search indexes or analytics pipelines
  • Creating deterministic text snapshots of rendered HTML for testing

Under The Hood

Architecture The project is a pnpm-style monorepo whose published html-to-text package sits on top of a shared base package. A call to convert first composes user options with the defaults via options-composer, then parses the HTML string with htmlparser2 into a DOM. Element formatting decisions come from the selectors array, which selderee/parseley compile into an efficient decision tree so each DOM node is matched against selectors in near-constant time rather than being tested one-by-one. Matched nodes are dispatched to formatters (in text-formatters.js, table-printer.js, and the base package’s generic formatters) that push content into a BlockTextBuilder; that builder — together with InlineTextBuilder and whitespace-processor — handles block spacing, inline concatenation, whitespace collapsing, and word wrapping to assemble the final string.

Tech Stack Written in modern JavaScript (ES2022, ESM-first) targeting Node.js >= 20.19. Runtime dependencies are minimal and focused: htmlparser2 for HTML parsing, dom-serializer for serialization, selderee with @selderee/plugin-htmlparser2 for selector compilation, and deepmerge-ts for options merging. The package ships dual CJS/ESM bundles produced by Rollup; tests run on AVA with c8 for coverage, and linting is handled by ESLint.

Code Quality The codebase is small, modular, and well-tested. The html-to-text package alone carries roughly two dozen AVA test files spread across general behavior, individual tag handling, and full-document snapshot fixtures. Source files are concise (the core is around 200 lines), documented with JSDoc typedefs, and cleanly separate parsing, selector matching, and text building into distinct modules. Options are validated and merged predictably, and the extensive CHANGELOG documents deprecations across major versions.

API Design The public surface is deliberately tiny — convert, its htmlToText alias, and compile — which makes the common case trivial while the selector and custom-formatter systems provide deep escape hatches for advanced needs. The 22 KB README documents every option, selector, and predefined formatter with runnable examples, and the compile pattern gives a clear, well-signposted path to high performance when processing batches. Naming is consistent and the migration notes between major versions are thorough.

Used by 22 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
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
69%
Other

Budibase

Low Code Platforms · No Code Platforms

28,220

Build AI agents, automations, and internal apps on a single open-source platform with full self-hosting control.

View details
92
Repo Health
81
Technical
63
Dependency
Built with
TypeScript69%
Svelte26%
Updated today
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
62%
Other

Flowise

Developer Tools · Automation · No Code Platforms

55,379

Drag-and-drop visual builder for AI agents, RAG pipelines, and multi-agent systems—deploy anywhere in minutes.

View details
91
Repo Health
77
Technical
64
Dependency
Built with
TypeScript62%
JavaScript27%
Updated 6 days ago
JavaScript
51%
MIT

Ghost

CMS · Blogging

54,795

Open source headless Node.js CMS for professional publishing, paid memberships, and newsletters with a fully owned audience.

View details
96
Repo Health
85
Technical
69
Dependency
Built with
JavaScript51%
TypeScript43%
Updated today
TypeScript
95%
AGPL 3.0

HeyForm

Forms Surveys · No Code Platforms

8,938

Open-source conversational form builder with AI generation, conditional logic, and 30+ integrations — self-host with full data ownership.

View details
86
Repo Health
67
Technical
69
Dependency
Built with
TypeScript95%
Updated today
TypeScript
61%
EPL-2.0

Huly Platform

Project Management · Team Chat · Collaboration

27,384

Open-source all-in-one workspace that replaces Linear, Jira, Slack, and Notion for product and engineering teams.

View details
90
Repo Health
86
Technical
64
Dependency
Built with
TypeScript61%
Svelte34%
Updated 1 weeks ago
TypeScript
99%
AGPL 3.0

Karakeep

Bookmarks Archiving

28,454

Self-hosted bookmark manager that captures links, notes, images, and PDFs with AI tagging, full-text search, and automatic archiving.

View details
88
Repo Health
76
Technical
67
Dependency
Built with
TypeScript99%
Updated 3 days ago

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