npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

html-textify

v1.0.2

Published

Convert html to plain text

Readme

html-textify

Convert HTML into plain text while optionally preserving formatting and keeping specific tags intact. Perfect for emails, logs, or text-only outputs.


Features

  • Convert HTML to plain text
  • Preserve formatting such as paragraphs, headings, lists, bold, italic, links, blockquotes, and tables
  • Optionally ignore specific tags to keep them in the output
  • Wrap output by word count or character length
  • Handles self-closing tags and nested content
  • Strips unknown tags and decodes common HTML entities ( , &, <, >)

Installation

pnpm add html-textify
# or
npm install html-textify
# or
yarn add html-textify

Usage

import { textify } from 'html-textify';

// Simple usage
const html = '<p>Hello <b>World</b></p>';
const plain = textify({ html });
console.log(plain); // "Hello **World**"

// Preserve formatting but ignore certain tags
const html2 = '<p>Paragraph <b>bold</b> <i>italic</i></p>';
const result = textify({
  html: html2,
  preserveFormatting: true,
  ignoreTags: ['b', 'i'],
});
console.log(result); // "Paragraph <b>bold</b><i>italic</i>"

// Strip all tags except ignored ones
const html3 = '<p>Paragraph <mark>highlighted</mark></p>';
const stripped = textify({
  html: html3,
  preserveFormatting: false,
  ignoreTags: ['mark'],
});
console.log(stripped); // "Paragraph <mark>highlighted</mark>"

// Wrap by words (max 2 words per line)
const html4 = '<p>one two three four five</p>';
const wrappedWords = textify({
  html: html4,
  preserveFormatting: false,
  wrapWords: 2,
});
console.log(wrappedWords);
/* Output:
one two
three four
five
*/

// Wrap by characters (max 10 characters per line)
const html5 = '<p>This is a test sentence for wrapping.</p>';
const wrappedChars = textify({
  html: html5,
  preserveFormatting: false,
  wrapLength: 10,
});
console.log(wrappedChars);
/* Output:
This is a
test
sentence
for
wrapping.
*/

API

textify(options: TextifyOptions): string

  • options.html (string) – HTML string to convert
  • options.preserveFormatting (boolean, default: true) – Whether to keep formatting like lists, headings, blockquotes, bold/italic
  • options.ignoreTags (string[], optional) – Tags to keep intact in output (e.g., ["b", "mark"])
  • options.wrapWords (number, optional) – Maximum words per line (takes priority over wrapLength)
  • options.wrapLength (number, optional) – Maximum characters per line