@alsharif/case-kit
v1.0.0
Published
Tiny, zero-dependency string case converter (camelCase, snake_case, kebab-case, PascalCase, CONSTANT_CASE, Title Case...) with a CLI.
Downloads
336
Maintainers
Readme
@alsharif/case-kit
Tiny, zero-dependency string case converter for Node.js — use it as a library or from the command line.
hello world → helloWorld · HelloWorld · hello_world · hello-world · HELLO_WORLD · hello.world · Hello World · Hello worldInstall
npm install @alsharif/case-kitOr run the CLI without installing:
npx @alsharif/case-kit camel "hello world"Library
import { camelCase, snakeCase, convert, words } from '@alsharif/case-kit';
camelCase('user_first-name'); // 'userFirstName'
snakeCase('XMLHttpRequest'); // 'xml_http_request'
convert('fooBar', 'constant'); // 'FOO_BAR'
words('myHTMLParser2Go'); // ['my', 'html', 'parser2', 'go']| Function | Case name | Example output |
| -------------- | ----------- | ----------------- |
| camelCase | camel | helloWorld |
| pascalCase | pascal | HelloWorld |
| snakeCase | snake | hello_world |
| kebabCase | kebab | hello-world |
| constantCase | constant | HELLO_WORLD |
| dotCase | dot | hello.world |
| titleCase | title | Hello World |
| sentenceCase | sentence | Hello world |
convert(text, caseName) picks a converter by name; converters is the full map. TypeScript types are included.
CLI
case-kit camel "hello world" # helloWorld
case-kit snake myVariableName # my_variable_name
echo "Some Title" | case-kit kebab # some-title
case-kit --all XMLHttpRequest # every case at onceLicense
MIT © alsharif
