A small, dependency-free, TypeScript-first toolkit for predictable string case conversion.
Unicode-aware tokenization, 11 built-in cases, and a single toCase() dispatcher — in ~3 kB gzip.
Most case-conversion libraries treat acronyms as opaque blobs or require manual configuration to split them. polycase recognizes acronym runs, numeric boundaries, and Unicode combining marks out of the box:
import { camelCase, tokenize, toCase } from "polycase";
// Acronym runs split correctly — no configuration needed
camelCase("getHTTPSUrl"); //=> "getHttpsUrl"
toCase("snake", "XMLParser"); //=> "xml_parser"
// Numeric boundaries detected automatically
toCase("kebab", "item3D"); //=> "item-3-d"
// Full Unicode support, including combining marks
tokenize("Cafe\u0301Noir"); //=> ["café", "noir"] (NFC-normalized)- Zero dependencies — nothing to audit, nothing to break
- ~3 kB gzip — ESM and CommonJS, with bundled types
- Predictable tokenization — separators, camelCase, PascalCase, acronym runs, and numeric boundaries all handled by one deterministic algorithm
- Idempotent — applying the same case twice always returns the same result
npm install polycase
pnpm add polycase
yarn add polycaseimport { camelCase, isCamelCase, titleCase, toCase, whichCases } from "polycase";
camelCase("hello world");
//=> "helloWorld"
titleCase("the lord of the rings");
//=> "The Lord of the Rings"
toCase("upper", "getHTTPSUrl", { separator: "." });
//=> "GET.HTTPS.URL"
isCamelCase("helloWorld");
//=> true
whichCases("HELLO_WORLD");
//=> ["constant"]For the full API reference, see packages/polycase/README.md.
| Case | Function | "helloWorld" |
"getHTTPSUrl" |
|---|---|---|---|
camel |
camelCase |
helloWorld |
getHttpsUrl |
capital |
capitalCase |
Hello World |
Get Https Url |
constant |
constantCase |
HELLO_WORLD |
GET_HTTPS_URL |
header |
headerCase |
Hello-World |
Get-Https-Url |
kebab |
kebabCase |
hello-world |
get-https-url |
lower |
lowerCase |
hello world |
get https url |
pascal |
pascalCase |
HelloWorld |
GetHttpsUrl |
sentence |
sentenceCase |
Hello world |
Get https url |
snake |
snakeCase |
hello_world |
get_https_url |
title |
titleCase |
Hello World |
Get Https Url |
upper |
upperCase |
HELLO WORLD |
GET HTTPS URL |
packages/polycase/ Published package — source, tests, and build output
config/ Shared build and lint configuration
pnpm install # install all dependencies
pnpm build # build the package
pnpm test # run all tests (vitest)
pnpm lint # check code style (oxlint)
pnpm format # auto-format with prettier
pnpm typecheck # run tsc --noEmitBuild or test the package in isolation:
pnpm --filter polycase build
pnpm --filter polycase testContributions are very welcome — from docs and examples to bug fixes, new plugins and features.
We’d love to hear your feedback — on API design, DX, docs, issues and ideas. Report them here.
Apache-2.0 — see LICENSE