Tiny TypeScript CLI to convert text case (camel/snake/kebab/pascal).
- TypeScript 73.3%
- JavaScript 26.7%
| .forgejo/workflows | ||
| scripts | ||
| src | ||
| .eslintrc.json | ||
| .gitignore | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| tsconfig.base.json | ||
| tsconfig.cjs.json | ||
| tsconfig.esm.json | ||
🔤 case-convert
Tiny, dependency-free TypeScript library + CLI for converting text between casing styles.
Ships as both ESM and CommonJS — import it or require it, your call.
✨ Features
| 🪶 Zero dependencies | No runtime deps — just plain, readable TypeScript |
| 🔁 Dual module support | Native ESM (import) and CommonJS (require) builds |
| 🧰 Library + CLI | Use it in code, or from the terminal |
| 🧵 Four case styles | camelCase, PascalCase, snake_case, kebab-case |
| 📦 Fully typed | .d.ts types included, no @types/* package needed |
| ✅ CI-checked | Every push is linted and built automatically |
📥 Installation
Not published to a registry yet — install straight from this repo:
git clone https://git.infinitewebworks.com/free-tools/case-convert.git
cd case-convert
npm install
npm run build
# use the CLI locally
node dist/cjs/cli.js camel "hello world"
# or link it so `case-convert` resolves as a global command
npm link
🖥️ CLI usage
npx case-convert <camel|pascal|snake|kebab> <text...>
$ npx case-convert camel "hello world example"
helloWorldExample
$ npx case-convert pascal "hello world example"
HelloWorldExample
$ npx case-convert snake "helloWorldExample"
hello_world_example
$ npx case-convert kebab "HelloWorld_Example"
hello-world-example
📦 Library usage
Import only what you need — every converter is a named export.
ESM
import { toCamelCase, toSnakeCase } from "case-convert";
toCamelCase("hello world"); // "helloWorld"
toSnakeCase("HelloWorld"); // "hello_world"
CommonJS
const { toKebabCase, toPascalCase } = require("case-convert");
toKebabCase("HelloWorld_Example"); // "hello-world-example"
toPascalCase("hello-world"); // "HelloWorld"
Dynamic lookup by name
Handy when the target case is only known at runtime (e.g. a CLI flag or config value):
import { converters, CaseName } from "case-convert";
function convert(style: CaseName, text: string): string {
return converters[style](text);
}
convert("snake", "helloWorld"); // "hello_world"
📚 API reference
| Export | Signature | Description |
|---|---|---|
toCamelCase |
(input: string) => string |
Converts to camelCase |
toPascalCase |
(input: string) => string |
Converts to PascalCase |
toSnakeCase |
(input: string) => string |
Converts to snake_case |
toKebabCase |
(input: string) => string |
Converts to kebab-case |
converters |
Record<CaseName, (input: string) => string> |
Lookup map of all four converters, keyed by name |
CaseName |
"camel" | "pascal" | "snake" | "kebab" |
Type of the valid case-name keys |
All converters accept mixed input — spaces, snake_case, kebab-case, or camelCase — and normalize before re-casing, so you can convert from any style to any style.
🛠️ Development
npm install
npm run lint # ESLint
npm run build # Builds dist/cjs + dist/esm side by side
CI runs lint and build as parallel jobs on every push and pull request — see
.forgejo/workflows/ci.yml.
📄 License
MIT