case-text-utils
v1.0.4
Published
A tiny, dependency-free utility to convert string cases like camelCase, snake_case, kebab-case, PascalCase, Title Case, UPPER_CASE, and more.
Maintainers
Readme
case-text-utils
A tiny utility (2KB) for converting between string cases: camelCase, snake_case, kebab-case, PascalCase, UPPERCASE, lowercase.
📦 Installation
npm i case-text-utils✨ Why use case-text-utils?
✅ Lightweight (under 2KB)
✅ Zero dependencies
✅ Written in clean ES modules
✅ Works in both Node.js & browser
✅ Developer-friendly API
✅ Supports 12+ popular case formats
✅ One-liner conversions with convertCase()
🛠 Usage
import {
toCamel,
toSnake,
toKebab,
toPascal,
toUpper,
toLower,
toTitle,
toCapital,
toConstant,
toDot,
toPath,
convertCase
} from 'case-text-utils';
toCamel('hello_world-text'); // "helloWorldText"
toSnake('helloWorldText'); // "hello_world_text"
toKebab('helloWorldText'); // "hello-world-text"
toPascal('hello_world-text'); // "HelloWorldText"
toUpper('hello world'); // "HELLO WORLD"
toLower('HELLO WORLD'); // "hello world"
toTitle('hello-world_case'); // "Hello World Case"
toCapital('hello world'); // "Hello world"
toConstant('helloWorld'); // "HELLO_WORLD"
toPath('helloWorldCase'); // "hello/world/case"
// 🔁 One-liner universal converter
convertCase('hello-world_case', 'pascal'); // "HelloWorldCase"
✅ Output Preview
console.log(toCamel('hello_world-case'));
// → "helloWorldCase"
console.log(convertCase('my-key_name', 'constant'));
// → "MY_KEY_NAME"