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

clean-text-utils

v1.3.0

Published

A Swiss Army Knife of text operations. Great for removing smart quotes, non-ASCII characters, emojis, and more.

Readme

clean-text-utils

A small, typed collection of text-cleaning utilities for Node.js 18 and newer.

Install

npm install clean-text-utils

Usage

Import individual functions from the package root:

import {
  replaceDiacritics,
  replaceSmartChars,
  stripEmoji,
} from "clean-text-utils";

let text = "Cr\u00E8me br\u00FBl\u00E9e \u{1F36E}";
text = stripEmoji(text);
text = replaceDiacritics(text);
text = replaceSmartChars(text);

console.log(text); // "Creme brulee"

The original namespace API remains available:

import cleanTextUtils from "clean-text-utils";

cleanTextUtils.get.capitalized("hello");
cleanTextUtils.replace.diacritics("cr\u00E8me br\u00FBl\u00E9e");
cleanTextUtils.strip.whitespace("hello world");

For the smallest bundle, and for browser applications, use a text-only subpath:

import stripWhitespace from "clean-text-utils/strip/whitespace";

stripWhitespace("hello world"); // "helloworld"

Each subpath has both a default export and a named export. The root entry includes the synchronous Node.js checksum utility and is therefore intended for Node.js. All subpaths except clean-text-utils/checksum are browser-safe.

Exports

| Named export | Subpath | | --- | --- | | capitalize | clean-text-utils/capitalize | | checksum | clean-text-utils/checksum | | filename | clean-text-utils/filename | | reverse | clean-text-utils/reverse | | isHexCode | clean-text-utils/is/hex-code | | replaceDiacritics | clean-text-utils/replace/diacritics | | replaceExoticChars | clean-text-utils/replace/exotic-chars | | replaceSmartChars | clean-text-utils/replace/smart-chars | | stripBom | clean-text-utils/strip/bom | | stripEmoji | clean-text-utils/strip/emoji | | stripExtraSpace | clean-text-utils/strip/extra-space | | stripGutenberg | clean-text-utils/strip/gutenberg | | stripNewlines | clean-text-utils/strip/newlines | | stripNonASCII | clean-text-utils/strip/non-ascii | | stripPunctuation | clean-text-utils/strip/punctuation | | stripWhitespace | clean-text-utils/strip/whitespace |

API

Get

  • capitalize(text) / get.capitalized(text) capitalizes the first character.
  • checksum(data, algorithm?) / get.checksum(data, algorithm?) returns a hexadecimal digest. sha256 is the default; sha, sha1, sha512, and md5 are also supported.
  • filename(pathOrUrl) / get.filename(pathOrUrl) returns the filename from a URL or Windows/POSIX path. Query strings and URL fragments are excluded.
  • reverse(text) / get.reversed(text) reverses text by Unicode grapheme cluster, preserving emoji sequences, flags, and combining marks.

checksum hashes strings directly for compatibility. Other supported JavaScript values use deterministic, type-aware serialization, so object key order does not affect the result and values such as false, 0, null, and undefined remain distinct. Circular data, functions, symbols, symbol-keyed properties, and opaque objects whose state cannot be inspected throw a TypeError instead of producing a misleading digest.

Is

  • isHexCode(text) / is.hexCode(text) checks three- and six-digit hexadecimal color codes.

Replace

  • replaceDiacritics(text) / replace.diacritics(text) transliterates diacritics, including decomposed combining marks.
  • replaceExoticChars(text) / replace.exoticChars(text) replaces diacritics and smart punctuation and removes a UTF-8 byte order mark.
  • replaceSmartChars(text) / replace.smartChars(text) replaces smart quotes, ellipses, and dashes with ASCII equivalents.

Strip

  • stripBom(text) / strip.bom(text) removes a UTF-8 byte order mark.
  • stripEmoji(text) / strip.emoji(text) removes emoji.
  • stripExtraSpace(text) / strip.extraSpace(text) collapses repeated whitespace and trims the result.
  • stripGutenberg(text) / strip.gutenberg(text) removes Project Gutenberg header and footer boilerplate.
  • stripNewlines(text) / strip.newlines(text) removes carriage returns and line feeds.
  • stripNonASCII(text) / strip.nonASCII(text) removes non-ASCII characters.
  • stripPunctuation(text) / strip.punctuation(text) removes common punctuation.
  • stripWhitespace(text) / strip.whitespace(text) removes all whitespace.

TypeScript declarations are included for the root API and every subpath.

License

MIT (c) Davis E. Ford