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

mr-case

v1.0.2

Published

55 functions to seamlessly transform strings, arrays, and object keys between different cases (camelCase, snake_case, kebab-case, PascalCase, Title Case, and more), clean and format text, extract URL components, and perform common text operations like mas

Downloads

214

Readme

mr-case 🤓

mr-case is a powerful and lightweight JavaScript utility library for case conversion, string formatting, and text manipulation. It provides a rich set of 55 functions to seamlessly transform strings, arrays, and object keys between different cases (camelCase, snake_case, kebab-case, PascalCase, Title Case, and more), clean and format text, extract URL components, and perform common text operations like masking, obfuscation, and abbreviation.

Whether you're dealing with API responses, filenames, database fields, SEO-friendly slugs, or user-generated content, mr-case makes string manipulation effortless and efficient.

npm License Downloads

📦 Installation

Install via npm

npm i mr-case

Usage

const mrCase = require('mr-case');

console.log(mrCase.toCamel('hello_world')); // "helloWorld"
console.log(mrCase.generateSlug('My Blog Post!')); // "my-blog-post"

API Reference (55 Functions)

Core Case Conversions

  1. toCamel(str: string): string → Converts underscore_case to camelCase.
    • "hello_world""helloWorld"
  2. toSnake(str: string): string → Converts camelCase to underscore_case.
    • "helloWorld""hello_world"
  3. toPascal(str: string): string → Converts snake_case or camelCase to PascalCase.
    • "hello_world""HelloWorld"
  4. toKebab(str: string): string → Converts snake_case or camelCase to kebab-case.
    • "hello_world""hello-world"
  5. toTitle(str: string): string → Converts any case to Title Case.
    • "hello world""Hello World"
  6. arrToCamel(arr: string[]): string[] → Converts an array of underscore_case strings to camelCase.
  7. arrToSnake(arr: string[]): string[] → Converts an array of camelCase strings to underscore_case.
  8. arrToPascal(arr: string[]): string[] → Converts an array of strings to PascalCase.
  9. arrToKebab(arr: string[]): string[] → Converts an array of strings to kebab-case.
  10. detectCase(str: string): "camel" | "snake" | "pascal" | "kebab" | "title" | "other" → Detects the case format of a string.

Object Key Conversions

  1. keysToCamel(obj: object): object → Converts object keys from snake_case to camelCase.
  2. keysToSnake(obj: object): object → Converts object keys from camelCase to underscore_case.
  3. keysToPascal(obj: object): object → Converts all object keys to PascalCase.
  4. keysToKebab(obj: object): object → Converts all object keys to kebab-case.
  5. deepCamel(obj: object): object → Converts all nested object keys to camelCase.
  6. deepSnake(obj: object): object → Converts all nested object keys to snake_case.
  7. deepPascal(obj: object): object → Converts all nested object keys to PascalCase.
  8. deepKebab(obj: object): object → Converts all nested object keys to kebab-case.
  9. autoConvert(str: string, target: "camel" | "snake" | "pascal" | "kebab" | "title"): string → Converts text to a specified format.
  10. isCamel(str: string): boolean → Checks if a string is in camelCase.

Text Formatting & Cleaning

  1. isSnake(str: string): boolean → Checks if a string is in snake_case.
  2. capitalize(str: string): string → Capitalizes the first letter.
  3. decapitalize(str: string): string → Converts the first letter to lowercase.
  4. capitalizeWords(str: string): string → Capitalizes the first letter of every word.
  5. decapitalizeWords(str: string): string → Lowercases the first letter of every word.
  6. swapCase(str: string): string → Swaps case of each letter.
  7. sentenceCase(str: string): string → Converts text to sentence case.
  8. randomCase(str: string): string → Randomly capitalizes letters.
  9. removeExtraSpaces(str: string): string → Trims and removes extra spaces.
  10. removeSpecialChars(str: string): string → Removes non-alphanumeric characters (except spaces).

Full-Text Case Conversion

  1. textToCamel(text: string): string → Converts sentences/paragraphs to camelCase.
  2. textToSnake(text: string): string → Converts sentences/paragraphs to snake_case.
  3. textToKebab(text: string): string → Converts sentences/paragraphs to kebab-case.
  4. textToPascal(text: string): string → Converts sentences/paragraphs to PascalCase.
  5. camelToText(str: string): string → Converts camelCase back to a readable sentence.
  6. snakeToText(str: string): string → Converts snake_case back to a readable sentence.
  7. kebabToText(str: string): string → Converts kebab-case back to a readable sentence.
  8. pascalToText(str: string): string → Converts PascalCase back to a readable sentence.
  9. reverseWords(str: string): string → Reverses word order.
  10. reverseString(str: string): string → Reverses the string.

SEO, Validation & Text Processing

  1. generateSlug(str: string): string → Converts a string into an SEO-friendly slug.
  2. extractDomain(url: string): string → Extracts domain from a URL.
  3. extractPath(url: string): string → Extracts the path from a URL.
  4. isPalindrome(str: string): boolean → Checks if a string is a palindrome.
  5. isAnagram(str1: string, str2: string): boolean → Checks if two words are anagrams.
  6. removeNumbers(str: string): string → Removes digits from a string.
  7. keepOnlyNumbers(str: string): string → Removes everything except numbers.
  8. truncate3dots(str: string, length: number): string → Truncates text with "..." if it exceeds length.
  9. shortenText(str: string, limit: number): string → Shortens text without cutting mid-word.
  10. replaceSeparator(str: string, from: string, to: string): string → Replaces a separator in a string.

Security & Privacy

  1. abbreviate(text: string): string → Converts "Machine Learning" to "ML".
  2. initials(name: string): string → Gets initials from a name ("John Doe""J.D.").
  3. obfuscateEmail(email: string): string → Hides part of an email address.
  4. maskString(str: string, visible: number): string → Masks a string while keeping first & last few characters.
  5. shortenText(str: string, limit: number): string → Keeps words within the limit instead of cutting mid-word.