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

@chaisser/string-wizard

v1.0.1

Published

Modern string manipulation utilities for TypeScript

Downloads

197

Readme

🧩 @chaisser/string-wizard

Advanced string manipulation with TypeScript type safety


✨ Features

  • 🎯 Type-safe - Full TypeScript support with no any types
  • 🔍 Pattern matching - Built-in regex patterns for common string operations
  • 🧽 Case conversion - Multiple case styles (camel, kebab, snake, pascal, etc.)
  • ✍️ Validation - Email, URL, phone, UUID validators
  • 🔤 Encoding/Decoding - Base64, URL encode/decode
  • 🎭 Masking - Sensitive data masking (emails, phones, credit cards)
  • 🧽 Truncation - Smart string truncation with ellipsis
  • 📊 Statistics - Word count, character count, reading time
  • 🔧 Search & Replace - Multiple search strategies (includes, startsWith, endsWith, indexOf)
  • 🎪 Normalization - Trim, collapse whitespace, remove diacritics
  • 📝 Templates - String interpolation and template literals
  • 🔗 Transformations - Reverse, shuffle, rotate, slice operations
  • 🧰 Generation - Random strings, UUIDs, tokens, unique strings
  • 🧾 Comparisons - Levenshtein distance, similarity, diff
  • 🔬 Regular Expressions - Build, test, and manipulate regex patterns
  • 🎨 Color Operations - Parse, validate, manipulate hex colors

📦 Installation

npm install @chaisser/string-wizard
# or
yarn add @chaisser/string-wizard
# or
pnpm add @chaisser/string-wizard

🚀 Quick Start

import {
  // Basic operations
  capitalize,
  lowerCase,
  upperCase,
  trim,
  isEmpty,

  // Case conversion
  camelCase,
  kebabCase,
  snakeCase,
  pascalCase,

  // Validation
  isEmail,
  isURL,
  isPhone,
  isUUID,

  // Masking
  maskEmail,
  maskPhone,
  maskCreditCard,

  // Generation
  randomString,
  randomUUID,

  // Statistics
  wordCount,
  characterCount,
  readingTime
} from '@chaisser/string-wizard';

// Basic operations
const str = 'hello world';
console.log(capitalize(str)); // Hello World
console.log(trim(str)); // hello world

// Validation
console.log(isEmail('[email protected]')); // true
console.log(isUUID('550e8400-e29b-41d4-a716-446655440144')); // true

// Masking
console.log(maskEmail('[email protected]')); // u***@example.com
console.log(maskCreditCard('4111111111111111', { showLastFour: true })); // 4111 **** **** 1111

📖 What It Does

This package provides a comprehensive toolkit for string manipulation in JavaScript and TypeScript. It handles everything from basic string operations to advanced regex-based pattern matching, validation, masking, and generation.


🎯 How It Works

The package is organized into modules, each handling a specific aspect of string manipulation:

  • Validation - Check if strings match expected patterns (emails, URLs, phones, UUIDs)
  • Case Conversion - Convert between different case formats (camel, kebab, snake, pascal)
  • Masking - Hide sensitive information while preserving format
  • Generation - Create random strings, tokens, and UUIDs
  • Statistics - Analyze strings (word count, character count, reading time)
  • Search & Replace - Find and replace content in strings
  • Encoding/Decoding - Encode/decode Base64 and URLs
  • Regular Expressions - Build, test, and manipulate regex patterns
  • Transformations - Manipulate strings (reverse, shuffle, rotate, slice operations)

🎨 What It's Useful For

  • Form Validation - Validate user inputs (emails, phone numbers, postal codes)
  • Data Privacy - Mask sensitive data (credit cards, social security numbers)
  • Text Processing - Case conversion, trimming, normalization
  • API Development - Slug generation, key creation, parameter naming
  • Security - Password strength checking, secure random token generation
  • UI/UX - Display formatted names, mask sensitive information
  • Data Analysis - Analyze text content (word count, reading time)
  • Testing - Generate test data (random strings, UUIDs)
  • Internationalization - Case conversion for different languages

💡 Usage Examples

Basic Operations

// Case conversion
const text = 'hello world';
console.log(camelCase(text)); // helloWorld
console.log(kebabCase(text)); // hello-world
console.log(snakeCase(text)); // hello_world
console.log(pascalCase(text)); // HelloWorld
console.log(upperCase(text)); // HELLO WORLD
console.log(lowerCase(text)); // hello world
console.log(capitalize(text)); // Hello world

// Trimming and cleaning
const messy = '  hello  world  ';
console.log(trim(messy)); // hello world
console.log(collapseWhitespace(messy)); // hello world
console.log(normalizeAccents('Café')); // Cafe

Validation

// Email validation
console.log(isEmail('[email protected]')); // true
console.log(isEmail('invalid')); // false
console.log(isEmail('user.name@domain')); // true (with TLD)

// Phone validation
console.log(isPhone('+1-555-123-4567')); // true
console.log(isPhone('123456')); // true (basic format)
console.log(isPhone('abc')); // false

// UUID validation
console.log(isUUID('550e8400-e29b-41d4-a716-446655440144')); // true (v4)
console.log(isUUID('00000000-0000-0000-000000000000')); // true (nil)
console.log(isUUID('not-a-uuid')); // false

// URL validation
console.log(isURL('https://example.com')); // true
console.log(isURL('example.com')); // false
console.log(isURL('ftp://example.com')); // true

// Postal code validation
console.log(isPostalCode('12345')); // true
console.log(isPostalCode('1234')); // true

Masking Sensitive Data

// Email masking
console.log(maskEmail('[email protected]')); // u***@example.com
console.log(maskEmail('user.name@domain')); // u*****@domain.com
console.log(maskEmail('[email protected]')); // l***@company.com

// Phone masking
console.log(maskPhone('+1-555-123-4567')); // +1-555-***-****
console.log(maskPhone('+1-800-555-1234')); // +1-800-***-***

// Credit card masking
console.log(maskCreditCard('4111111111111111', { showLastFour: true })); // 4111 **** **** 1111
console.log(maskCreditCard('4111111111111111')); // **** **** **** ****

// SSN masking
console.log(maskSSN('123-45-6789')); // ***-**-****

Random Generation

// Random string
console.log(randomString(10)); // Random 10-character string
console.log(randomString(10, { lowercase: true, numbers: true })); // Random 10-char with lower+nums

// UUID generation
console.log(randomUUID()); // Random UUID v4
console.log(randomUUID('v7')); // Random UUID v7

// Custom alphabet
console.log(randomString(10, { alphabet: 'abcdef' })); // Random from custom charset
console.log(randomString(10, { lowercase: true, uppercase: true, numbers: true, symbols: true })); // Mix all types

String Statistics

const text = 'Hello World! This is a test string.';

// Character count
console.log(characterCount(text)); // { length: 34, letters: 24, digits: 2, spaces: 7, symbols: 1 }

// Word count
console.log(wordCount(text)); // 8
console.log(wordCount('The quick brown fox jumps over the lazy dog')); // 9

// Letter frequency
console.log(letterFrequency(text)); // { H: 1, e: 3, l: 3, o: 4, r: 1, d: 1, t: 2, W: 1, '!': 2, T: 1, s: 3, i: 2, a: 1, h: 1 }

// Unique characters
console.log(uniqueCharacters(text)); // 8 (H, e, l, o, r, d, t, W, !)

Search & Replace

const text = 'hello world hello world';

// Find operations
console.log(contains(text, 'hello')); // true
console.log(startsWith(text, 'hello')); // true
console.log(endsWith(text, 'world')); // true
console.log(includes(text, 'world')); // true

// Index operations
console.log(indexOf(text, 'world')); // 6 (first occurrence)
console.log(lastIndexOf(text, 'world')); // 18 (last occurrence)

// Replace operations
console.log(replaceAll(text, 'hello', 'hi')); // hi world hi world
console.log(replaceAt(text, 0, 'HI')); // HIello world hello world
console.log(replaceRange(text, 0, 5, 'HEY')); // HEY world hello world

Regular Expressions

// Test regex patterns
console.log(testEmailRegex('[email protected]')); // true
console.log(testURLRegex('https://example.com')); // true
console.log(testPhoneRegex('+1-555-123-4567')); // true

// Build regex from components
const pattern = buildRegex('hello', { anyChar: true, digits: true });
console.log(testRegex(pattern, 'h3llo777')); // true (h = any, 3 = digit, etc.)

// Extract data from regex
const email = '[email protected]';
const { match, groups } = extractEmailRegex(email);
console.log(match); // [email protected]
console.log(groups); // { domain: 'example.com', local: 'contact' }

Encoding/Decoding

// Base64
const original = 'hello world';
const encoded = toBase64(original);
console.log(encoded); // aGVsbG8gd29yb3Js=
const decoded = fromBase64(encoded);
console.log(decoded); // hello world

// URL encode/decode
const url = 'https://example.com/search?q=hello world';
const encodedURL = encodeURL(url);
console.log(encodedURL); // https://example.com/search?q=hello%20world
const decodedURL = decodeURL(encodedURL);
console.log(decodedURL); // https://example.com/search?q=hello world

// Encode URI component
const encodedComponent = encodeURIComponent('hello world');
console.log(encodedComponent); // hello%20world

🔗 Related Packages

Explore our other utility packages in the @chaisser namespace:


🔒 License

MIT - Free to use in personal and commercial projects


👨 Developed by

Doruk Karaboncuk [email protected]


📄 Repository


🤝 Contributing

Contributions are welcome! Feel free to:

  • Report bugs
  • Suggest new features
  • Submit pull requests
  • Improve documentation

📞 Support

For issues, questions, or suggestions, please reach out through:


Made with ❤️ by @chaisser

npm license downloads typescript