CaPiTaLiZe StRiNgS in 29 ways!
A lightweight, zero-dependency library for text capitalization and transformation. Perfect for formatting strings for code, URLs, display, or fun!
- 29 transformation styles - More than any other library!
- Zero dependencies - Lightweight and fast
- ESM native - Modern JavaScript modules
- 98% test coverage - Thoroughly tested
npm install capstringimport capstring from 'capstring';
capstring('hello world', 'title'); // 'Hello World'
capstring('hello world', 'camel'); // 'helloWorld'
capstring('hello world', 'kebab'); // 'hello-world'
capstring('hello world', 'constant'); // 'HELLO_WORLD'
capstring('hello world', 'leet'); // 'h3££0 w0r£d'
capstring('hello world', 'hashtag'); // '#HelloWorld'| Style | Input | Output |
|---|---|---|
same |
Hello World | Hello World |
none |
Hello World | (empty) |
proper |
Hello World | Hello World |
title |
hello world | Hello World |
sentence |
hello world | Hello world |
upper |
hello world | HELLO WORLD |
lower |
HELLO WORLD | hello world |
swap |
Hello World | hELLO wORLD |
| Style | Input | Output |
|---|---|---|
camel |
hello world | helloWorld |
pascal |
hello world | HelloWorld |
snake |
hello world | hello_world |
kebab |
hello world | hello-world |
slug |
hello world | hello-world |
constant |
hello world | HELLO_WORLD |
python |
hello world | HELLO_WORLD |
dot |
hello world | hello.world |
path |
hello world | hello/world |
train |
hello world | Hello-World |
| Style | Input | Output |
|---|---|---|
leet |
hello world | h3££0 w0r£d |
reverse |
hello world | dlrow olleh |
sponge |
hello world | HeLlO WoRlD |
mock |
hello world | hElLo wOrLd |
alternate |
hello world | hElLo WoRlD |
crazy |
hello world | (deterministic random) |
random |
hello world | (random case) |
| Style | Input | Output |
|---|---|---|
hashtag |
hello world | #HelloWorld |
acronym |
as soon as possible | ASAP |
rot13 |
hello | uryyb |
flip |
hello | ollǝɥ |
Transform a string to the specified style.
import capstring from 'capstring';
capstring('hello world', 'title'); // 'Hello World'
capstring('hello world'); // 'hello world' (default: same)
capstring(123); // false (invalid input)Get an array of all supported style names.
import { getStyles } from 'capstring';
getStyles(); // ['same', 'none', 'proper', 'title', ...]Check if a style is supported.
import { isValidStyle } from 'capstring';
isValidStyle('kebab'); // true
isValidStyle('invalid'); // falseFrozen array of all style names.
import { STYLES } from 'capstring';
STYLES.length; // 29Looking for an API? Check out cAPIta - a full REST API powered by capstring!
curl https://your-api.com/title/hello%20world
# {"input":"hello world","output":"Hello World","cap":"title"}npm install # Install dependencies
npm test # Run tests
npm run lint # Run linter
npm run test:coverage # Test with coveragePlease read CONTRIBUTING.md for details on the code of conduct and the process for submitting pull requests.
This project uses Semantic Versioning 2.0.
- Node.js 18+
- ES modules (
import/export)
MIT - Copyright 2016-2026 Brian Funk