@lacspace/case
v1.0.0
Published
Convert strings between cases — camelCase, PascalCase, snake_case, kebab-case, CONSTANT_CASE, Title Case, Sentence case. Handles acronyms & numbers. Zero-dependency, isomorphic.
Maintainers
Readme
@lacspace/case
Convert strings between cases — camelCase, PascalCase, snake_case, kebab-case, CONSTANT_CASE, Title Case & more.
The string-case toolkit — correct on the tricky inputs (acronyms like
XMLHttpRequest, numbers likev2, mixed separators). One tiny, typed, dependency-free package instead of a grab-bag of one-function modules.
Install
npm install @lacspace/case # or pnpm add / yarn add / bun addUse
import { camelCase, snakeCase, kebabCase, constantCase, titleCase, changeCase } from "@lacspace/case";
camelCase("foo_bar-baz"); // "fooBarBaz"
snakeCase("fooBarBaz"); // "foo_bar_baz"
kebabCase("XMLHttpRequest"); // "xml-http-request"
constantCase("fooBar"); // "FOO_BAR"
titleCase("hello_world"); // "Hello World"
changeCase("fooBar", "kebab"); // "foo-bar" ← pick the case at runtimeAPI
| Function | Example |
| --- | --- |
| camelCase | fooBar |
| pascalCase | FooBar |
| snakeCase | foo_bar |
| kebabCase | foo-bar |
| constantCase | FOO_BAR |
| dotCase / pathCase | foo.bar / foo/bar |
| titleCase / sentenceCase | Foo Bar / Foo bar |
| capitalize | Foo |
| words(str) | ["foo","bar"] — the splitter behind them all |
| changeCase(str, name) | runtime case by name |
words() splits on spaces, _ - . /, camelCase boundaries, acronym boundaries and letter/number boundaries — so every conversion is consistent.
Licensing
This package is free under the Lacspace Free Licence — MIT-equivalent freedoms. Use it in personal and commercial projects at no cost; just keep the notice.
Not every Lacspace package is free. We also offer Commercial, Client-specific and Private packages under separate terms — see the Lacspace Licence Centre.
Part of the Lacspace ecosystem — zero-dependency, isomorphic TypeScript packages.
