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

@razomy/string-case

v0.0.1-beta.4

Published

Utility functions for advanced string casing conversions and manipulations

Readme

@razomy/string-case

License CI Status minzipped size TypeScript Node.js Version npm version npm downloads GitHub stars

Npm | Npmx | GitHub | Io

Utility functions for advanced string casing conversions and manipulations

🚀 Start

Install

npm i @razomy/string-case

Import

import * as stringCase from '@razomy/string-case';
// or
import { abbreviation } from '@razomy/string-case';

📑 Table of Contents

Functions

📚 Documentation

Functions

abbreviation

abbreviation(text: string): string

Get abbreviation from string. Takes a string of words separated by spaces, hyphens, or underscores, and returns an abbreviation formed by concatenating the first letter of each word.

Examples

abbreviation('Hello World'); // HW
abbreviation('node package manager'); // npm
abbreviation('Read-Only_Memory'); // ROM

alternatingCase

alternatingCase(text: string): string

Convert string to aLtErNaTiNg cAsE (SpongeBob case). Alternates cases based on the index of the character (ignoring spaces is optional, this implementation alternates strictly by character position).

Examples

alternatingCase('hello world'); // hElLo wOrLd
alternatingCase('typescript'); // tYpEsCrIpT

camelCase

camelCase(text: string): string

Converts a string to camel case. Takes an input string in any common format (space-separated, kebab-case, snake_case, PascalCase, etc.) and converts it to camelCase. The function first normalizes the string by identifying word boundaries (including transitions between acronyms, letters/numbers, and common delimiters like spaces, hyphens, dots, and underscores), then joins the segments together with the first segment in lowercase and each subsequent segment capitalized.

Examples

camelCase('Foo Bar'); // fooBar
camelCase('--foo-bar--'); // fooBar
camelCase('__FOO_BAR__'); // fooBar

capitalize

capitalize(text: string): string

Converts the first character of string to upper case and the remaining to lower case. Takes an input string and returns a new string where the first character is converted to upper case and all remaining characters are converted to lower case. This is useful for normalizing the casing of words regardless of their original casing.

Examples

capitalize('razomy'); // Razomy
capitalize('RAZOMY'); // Razomy
capitalize('rAZOMY'); // Razomy

constantCase

constantCase(text: string): string

Convert string to CONSTANT_CASE (macro case). Converts a given string from any common casing convention (camelCase, kebab-case, snake_case, space-separated, etc.) to CONSTANT_CASE (also known as macro case or screaming snake case), where all letters are uppercased and words are separated by underscores.

Examples

constantCase('hello world'); // HELLO_WORLD
constantCase('camelCaseString'); // CAMEL_CASE_STRING
constantCase('kebab-case-test'); // KEBAB_CASE_TEST

dotCase

dotCase(text: string): string

Convert string to dot.case. Converts a given string into dot.case format by splitting the input on camelCase boundaries, non-alphanumeric characters, and whitespace, then joining the resulting lowercase words with dots.

Examples

dotCase('Hello World'); // hello.world
dotCase('camelCaseString'); // camel.case.string
dotCase('foo_bar'); // foo.bar

headerCase

headerCase(text: string): string

Convert string to Header-Case (Train-Case). Converts a given string into Header-Case (also known as Train-Case), where each word is capitalized and separated by hyphens. The function handles various input formats including camelCase, snake_case, and strings with arbitrary delimiters by first splitting the text into individual words, capitalizing the first letter of each word, lowercasing the rest, and then joining them with hyphens.

Examples

headerCase('hello world'); // Hello-World
headerCase('camelCaseString'); // Camel-Case-String
headerCase('session_id'); // Session-Id

humanize

humanize(text: string): string

Convert a string to a human-readable form. Transforms a string from common programming naming conventions (camelCase, snake_case, kebab-case) into a human-readable sentence. It splits words by detecting camelCase boundaries, underscores, and hyphens, normalizes whitespace, converts the result to lowercase, and capitalizes the first letter.

Examples

humanize('camelCase'); // Camel case
humanize('snake_case_string'); // Snake case string
humanize('kebab-case-string'); // Kebab case string

isAlpha

isAlpha(text: string): boolean

Checks if the string contains only alphabetic characters. Determines whether the given string consists exclusively of alphabetic characters (a-z, A-Z). Returns false for empty strings, strings containing digits, whitespace, special characters, or any non-alphabetic characters. The check is performed using a regular expression that matches one or more alphabetic characters spanning the entire string.

Examples

isAlpha('Razomy'); // true
isAlpha('R4zomy'); // false
isAlpha(''); // false

isAlphanumeric

isAlphanumeric(text: string): boolean

Check if the string contains only alphanumeric characters. Tests whether the given string consists exclusively of alphanumeric characters (letters a-z, A-Z and digits 0-9) using a regular expression. Returns false for empty strings, strings containing spaces, special characters, or any non-alphanumeric content.

Examples

isAlphanumeric('Razomy1'); // true
isAlphanumeric('Razomy-String'); // false
isAlphanumeric(' '); // false

isLowerCase

isLowerCase(text: string): boolean

Checks if the string is lower case. Determines whether the entire input string is in lower case by comparing it to its lower-cased equivalent. Non-alphabetic characters (such as digits, spaces, and symbols) do not affect the result, as they have no case and remain unchanged by the lower case conversion.

Examples

isLowerCase('razomy'); // true
isLowerCase('Razomy'); // false
isLowerCase('string with 123'); // true

isUpperCase

isUpperCase(text: string): boolean

Check if a string is upper case. Determines whether the given string is entirely in upper case by comparing it to its upper-cased transformation. Returns true only if every character in the string is already upper case (i.e., the string is identical to the result of calling toUpperCase() on it).

Examples

isUpperCase('HELLO'); // true
isUpperCase('Hello'); // false
isUpperCase('hello'); // false

kebabCase

kebabCase(text: string): string

Convert string to kebab case. Converts a given string to kebab-case by handling acronyms, camelCase, letter-number boundaries, and various delimiters (spaces, underscores, hyphens, dots). Leading and trailing separators are stripped, and the result is lowercased.

Examples

kebabCase('fooBar'); // foo-bar
kebabCase('Foo Bar'); // foo-bar
kebabCase('__FOO_BAR__'); // foo-bar

lowerCase

lowerCase(text: string): string

Converts a string to lower case. Converts all characters in the given string to their lower case equivalents using the built-in toLowerCase method. The original string is not modified; a new lower cased string is returned.

Examples

lowerCase('RAZOMY'); // razomy
lowerCase('Test'); // test
lowerCase('FOO Bar'); // foo bar

pascalCase

pascalCase(text: string): string

Convert string to pascal case. Converts a given string to PascalCase by splitting it into words (handling spaces, underscores, and camelCase/UPPERCASE boundaries), capitalizing the first letter of each word, lowercasing the rest, and joining them together without any separator.

Examples

pascalCase('foo bar'); // FooBar
pascalCase('foo_bar'); // FooBar
pascalCase('FOO BAR'); // FooBar

pathCase

pathCase(text: string): string

Convert string to path/case. Converts a given string into path/case format by splitting it on camelCase boundaries, non-alphanumeric characters, and whitespace, then joining the resulting lowercase words with forward slashes.

Examples

pathCase('Hello World'); // hello/world
pathCase('camelCaseString'); // camel/case/string
pathCase('foo_bar'); // foo/bar

reverse

reverse(text: string): string

Reverses the given string. Reverses the order of characters in the given string by spreading it into an array of individual characters, reversing the array, and joining the characters back into a string. This approach correctly handles multi-byte Unicode characters (such as emojis) by using the spread operator, which splits on code points rather than code units.

Examples

reverse('abc'); // cba
reverse('qwerty'); // ytrewq
reverse('123'); // 321

sentenceCase

sentenceCase(text: string): string

Convert string to Sentence case. Only the first letter of the result is capitalized, the rest is lowercase.

Examples

sentenceCase('helloWorld'); // Hello world
sentenceCase('HELLO WORLD'); // Hello world
sentenceCase('foo_bar_baz'); // Foo bar baz

slugify

slugify(text: string): string

Convert string to url friendly slug. Converts a given string into a URL-friendly slug by normalizing unicode characters (removing diacritics/accents), converting to lowercase, replacing non-alphanumeric characters with hyphens, and trimming leading/trailing hyphens.

Examples

slugify('Hello World'); // hello-world
slugify('Foo & Bar'); // foo-bar
slugify('Crème Brûlée'); // creme-brulee

snakeCase

snakeCase(text: string): string

Convert string to snake case. Converts a given string to snake_case format by handling acronyms, camelCase, letter-to-number and number-to-letter boundaries, and replacing common delimiters (spaces, hyphens, dots) with underscores. The result is trimmed of leading/trailing underscores and converted to lowercase.

Examples

snakeCase('fooBar'); // foo_bar
snakeCase('Foo Bar'); // foo_bar
snakeCase('FOO-BAR'); // foo_bar

swapCase

swapCase(text: string): string

Convert string by swapping the case of every character. Uppercase becomes lowercase, and lowercase becomes uppercase.

Examples

swapCase('Hello World'); // hELLO wORLD
swapCase('camelCase'); // CAMELcASE
swapCase('123 ABC xyz'); // 123 abc XYZ

titleCase

titleCase(text: string): string

Convert string to title case. Converts the input string to title case by first lowercasing the entire string, then capitalizing the first letter of each word. Word boundaries are determined by the \b regex anchor, so hyphenated words and other non-alphabetic separators only trigger capitalization at the start of each word boundary segment.

Examples

titleCase('foo bar'); // Foo Bar
titleCase('HELLO WORLD'); // Hello World
titleCase('one-two'); // One-two

upperCase

upperCase(text: string): string

Convert string to upper case. Converts all characters in the given string to their upper-case equivalents using the built-in String.prototype.toUpperCase method. The original string is not modified; a new upper-cased string is returned.

Examples

upperCase('test'); // TEST
upperCase('Hello World'); // HELLO WORLD
upperCase('razomy'); // RAZOMY

🕊️ Vision

"Razomy" means Together—you and me.
We act as catalysts, turning natural chaos into clarity through open collaboration.
By building honest, reliable systems, we empower humanity and create a foundation for peace.
We foster a borderless environment driven by quality code and mutual support.
Join us to build this future—one commit at a time.

💖 Fuel Our Shared Future

We can't build this without you. If this library has saved you time or helped turn chaos into clarity in your own projects, please consider backing the developers behind it. Building reliable, open-source tools takes immense time and energy. Your sponsorship isn't just a donation; it’s the fuel that keeps this project actively maintained, bug-free, and thriving for everyone who relies on it.

Help us keep the momentum going. Choose how you want to light the way:

🤝 Contributing

Contributions, issues and feature requests are welcome! Feel free to check issues page.

📝 License

Copyright © 2026 Razomy. This project is MIT licensed.

🐛 Reporting Issues

We use GitHub Issues as the official bug tracker for this project.

Before opening a new issue, please check if your problem has already been reported. If it hasn't, please open a new issue here: GitHub Issues: razomy/js

When reporting a bug, please include:

  • A brief description of the issue.
  • Steps to reproduce the bug.
  • Your current environment (Node version, OS, etc.).