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

utils4strings

v0.0.1

Published

A collection of string utility functions for manipulating strings in JavaScript and TypeScript

Downloads

3

Readme


Utils4strings - Enhance Your String Operations

Description

Utils4strings is a comprehensive library designed to simplify string manipulation tasks. From case conversions and validation to trimming, padding, and encoding, this library provides a set of powerful functions to perform common string operations with ease.

The library includes utility methods for string formatting, character counting, string manipulation, and more. It can be used in both JavaScript and TypeScript projects.

Installation

To install utils4strings, simply run the following command using npm:

npm i utils4strings

Features

String Case Utilities

  • Capitalize: Capitalize the first letter of a string.
  • LowerCase: Convert a string to lowercase.
  • TitleCase: Convert a string to title case (capitalize the first letter of each word).
  • CapitalizeSentences: Capitalize the first letter of each sentence.
  • CamelCase: Convert a string to camel case (first word lowercase, subsequent words capitalized).
  • PascalCase: Convert a string to Pascal case (capitalized first letter of each word).
  • SnakeCase: Convert a string to snake case (words separated by underscores).
  • KebabCase: Convert a string to kebab case (words separated by hyphens).

String Trimming and Removal Utilities

  • truncate: Truncate a string to a specified length and append ellipsis.
  • removeWhitespace: Remove all whitespace characters from a string.
  • removeNonAlphaNumeric: Remove all non-alphanumeric characters.
  • removeNonNumeric: Remove all non-numeric characters.
  • removeTrailingWhitespace: Remove trailing whitespace from a string.
  • removeLeadingWhitespace: Remove leading whitespace from a string.

Padding Utilities

  • padStart: Pad a string from the start with a specified character until it reaches a desired length.
  • padEnd: Pad a string from the end with a specified character until it reaches a desired length.

Repetition and Reversal

  • repeat: Repeat a string a specified number of times.
  • reverse: Reverse the characters in a string.

Replacement Utilities

  • replace: Replace the first occurrence of a substring in a string.
  • replaceAll: Replace all occurrences of a substring in a string.

Splitting and Joining Utilities

  • split: Split a string into an array of substrings based on a separator.
  • join: Join an array of substrings into a single string using a separator.

Validation Utilities

  • isEmpty: Check if a string is empty or contains only whitespace.
  • isAlpha: Check if a string contains only alphabetic characters.
  • isAlphaNumeric: Check if a string contains only alphanumeric characters.
  • isNumeric: Check if a string contains only numeric characters.
  • isLowerCase: Check if a string is in lowercase.
  • isUpperCase: Check if a string is in uppercase.
  • isPalindrome: Check if a string is a palindrome.
  • isAnagram: Check if two strings are anagrams of each other.

Counting Utilities

  • countWords: Count the number of words in a string.
  • countCharacters: Count the number of characters in a string.
  • countOccurrences: Count the occurrences of a substring in a string.
  • countAlpha: Count the number of alphabetic characters in a string.

Miscellaneous Utilities

  • stripTags: Remove HTML tags from a string.
  • splitWords: Split a string into words by removing non-alphabetic characters.
  • slugify: Create a URL-friendly slug from a string.

Encoding and Decoding Utilities

  • toBase64: Encode a string to Base64 format.
  • fromBase64: Decode a Base64-encoded string.
  • toBase64Url: Encode a string to Base64 URL-safe format.
  • fromBase64Url: Decode a Base64 URL-safe encoded string.

HTML Utilities

  • escapeHTML: Escape special HTML characters in a string.
  • unescapeHTML: Unescape HTML-encoded characters in a string.

Miscellaneous Utilities

  • insertAt: Insert a substring at a specific index in a string.
  • extractBetween: Extract a substring between two given substrings.
  • hashString: Hash a string using a specified algorithm (default is sha256).
  • compareIgnoreCase: Compare two strings ignoring case.
  • generateRandomString: Generate a random string of a given length.
  • matchPattern: Check if a string matches a specified regular expression pattern.
  • padWithCustomString: Pad a string with a custom string until it reaches a desired length.
  • removeDuplicates: Remove duplicate characters from a string.
  • CountMostCommonCharacters: Count the occurrences of each character in a string.
  • countVowels: Count the number of vowels in a string.
  • countConsonants: Count the number of consonants in a string.
  • countLines: Count the number of lines in a string.
  • countSentences: Count the number of sentences in a string.
  • countParagraphs: Count the number of paragraphs in a string.
  • countSpaces: Count the number of spaces in a string.
  • countTabs: Count the number of tabs in a string.
  • countSpecialCharacters: Count the number of special characters in a string.
  • countMostUsedWords: Count the occurrences of each word in a string.

Usage/Examples

const {
    Capitalize,
    LowerCase,
    titleCase,
    truncate,
    hashString,
    toBase64,
    generateRandomString,
} = require('utils4strings');

// Capitalize the first letter of a string
console.log(Capitalize('hello world')); // "Hello world"

// Convert string to lowercase
console.log(LowerCase('HELLO WORLD')); // "hello world"

// Convert string to title case
console.log(titleCase('hello world example')); // "Hello World Example"

// Truncate a string with ellipsis
console.log(truncate('This is a very long sentence.', 10)); // "This is a..."

// Hash a string using SHA-256
console.log(hashString('hello world')); // "a591a6d40bf420404a011733cfb7b190d62c65bf0bcda6f6f5c5b5e6a98a1c4c"

// Encode a string to Base64
console.log(toBase64('hello world')); // "aGVsbG8gd29ybGQ="

// Generate a random string of length 10
console.log(generateRandomString(10)); // Example: "aXx8A2dHhJ"

Notes

  • String Utilities provides a wide range of functions for manipulating strings, making it ideal for general-purpose string processing tasks.
  • All functions are simple to use and return the expected results in various scenarios.
  • Most functions in this library are synchronous, making them suitable for immediate use in your code.

Authors

License

MIT License

String Utilities - Simplify your string operations!