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 🙏

© 2025 – Pkg Stats / Ryan Hefner

text-toolbox

v1.0.15

Published

[![npm version][npm-version-src]][npm-version-href] [![npm downloads][npm-downloads-src]][npm-downloads-href] [![Codecov][codecov-src]][codecov-href]

Readme

Text Toolbox [WIP]

npm version npm downloads Codecov

A high-performance TypeScript library for string similarity and distance algorithms—complete with robust utilities for string cleaning, normalization, and format transformation.

  • Fully tree-shakeable
  • Zero dependencies

Installation

# pnpm
pnpm add text-toolbox

# npm
npm install text-toolbox

# yarn
yarn add text-toolbox

Algorithms

Distance

  • levenshtein() - Calculates the Levenshtein distance between two strings.
  • damerauLevenshtein() - Calculates the Damerau-Levenshtein distance between two strings.
  • diceCoefficient() - Calculates the Dice coefficient between two strings.
  • cosineDistance() - Calculates the cosine distance between two strings.

Similarity

  • cosineSimilarity() - Calculates the cosine similarity between two strings.
  • jaroWinkler() - Calculates the Jaro-Winkler similarity between two strings.

Metaphonics

  • metaphoneThree() - Implements the Metaphone 3 algorithm for phonetic encoding.
  • doubleMetaphone() - Implements the Double Metaphone algorithm for phonetic encoding.

String Cleaning Utilities

A set of helper functions to normalize and sanitize strings before comparison.

Whitespace Normalizers

Clean up inconsistent or unwanted whitespace:

  • ensureSpaceAfterPunctuation() - Ensures there is exactly one space after punctuation marks like . , : ; ! ? (if followed by a word character).
  • normalizePunctuationSpacing() - Normalizes spaces around punctuation by removing spaces before, ensuring one space after, optionally removing extra spaces, and allowing custom tight spacing for specific characters (e.g., -, ').
  • normalizeWhitespace() - Trims leading/trailing whitespace and collapses all internal whitespace (spaces, tabs, newlines) to a single space.
  • removeAllWhitespace() - Removes all whitespace characters (spaces, tabs, newlines) from the string.
  • removeExtraSpaces() - Replaces multiple consecutive spaces with a single space (ignores tabs/newlines).
  • removeLeadingWhitespace() - Removes whitespace at the beginning of the string.
  • removeTrailingWhitespace() - Removes whitespace at the end of the string.
  • removeWhitespaceBeforePunctuation() - Removes any whitespace directly before punctuation like . , : ; ! ?.

Special Character Cleaners

Remove or replace problematic characters and formatting:

  • removeCombiningMarks() - Removes all types of combining marks from a string.
  • removeModifiers() - Removes modifier letters and symbols from a string.
  • removeDiacritics() - Removes diacritic marks (accents) from characters in a string.
  • removeHtmlTags() - Strips HTML tags from the input string.
  • removeIllegalCharacters() - Removes illegal or non-printable characters from the string.
  • removeNewLineCharacters() - Removes newline (\n) and carriage return (\r) characters from the string.
  • removeNonASCII() - Removes all non-ASCII characters from the string.
  • removeControlCharacters() - Strips control characters from the string.
  • removePunctuation() - Removes punctuation characters from the string.
  • replaceCompatibilityCharacters() - Normalizes text by converting non-ASCII characters (like æ, ø, ß) to their closest ASCII representation (ae, oe, ss).
  • replaceSmartTypography() - Converts smart typography characters (like curly quotes and em-dashes) to their standard ASCII equivalents.
  • stripEmoji() - Removes all emoji characters from the string.

Text Transformers

  • removeDuplicateWords() - Removes duplicate words that appear consecutively in a string.
  • removeTitlePrefix() - Removes common prefixes from titles (e.g., "The", "A", "An").
  • removeTitleSuffix() - Removes common suffixes from titles.

String Case Formatters

  • camelCase() - Converts a string to camel case, where the first word is lowercase and each subsequent word starts with an uppercase letter, with no spaces or punctuation.
  • constantCase() - Converts a string to constant case, where each word is capitalized and separated by underscores.
  • dotCase() - Converts a string to dot case, where each word is lowercase and separated by periods.
  • kebabCase() - Converts a string to kebab case, where each word is lowercase and separated by hyphens.
  • pascalCase() - Converts a string to Pascal case, where each word starts with an uppercase letter and there are no spaces or punctuation.
  • pathCase() - Converts a string to path case, where each word is lowercase and separated by slashes.
  • sentanceCase() - Converts a string to sentence case, where only the first letter of the first word is capitalized.
  • snakeCase() - Converts a string to snake case, where each word is lowercase and separated by underscores.
  • titleCase() - Converts a string to title case, where the first letter of each word is capitalized.

String Tokenizers

  • fingerprint() - Normalizes text by removing special characters, creating sorted unique word lists.

Presets

  • normalizeName() - Normalizes names by applying a series of transformations to standardize formatting.

Security

This package is safe :)

License

MIT