Tiny TypeScript CLI to convert text case (camel/snake/kebab/pascal).
  • TypeScript 73.3%
  • JavaScript 26.7%
Find a file
free-tools dbba3b67cf
All checks were successful
CI / lint (push) Successful in 26s
CI / build (push) Successful in 29s
Fix README install instructions (not published to any registry)
2026-08-25 02:11:06 -04:00
.forgejo/workflows Add case-convert TypeScript CLI with lint/build CI 2026-08-25 01:57:38 -04:00
scripts Add library exports, dual ESM/CJS build, comprehensive README 2026-08-25 02:05:11 -04:00
src Add library exports, dual ESM/CJS build, comprehensive README 2026-08-25 02:05:11 -04:00
.eslintrc.json Add case-convert TypeScript CLI with lint/build CI 2026-08-25 01:57:38 -04:00
.gitignore Add case-convert TypeScript CLI with lint/build CI 2026-08-25 01:57:38 -04:00
package-lock.json Add case-convert TypeScript CLI with lint/build CI 2026-08-25 01:57:38 -04:00
package.json Add library exports, dual ESM/CJS build, comprehensive README 2026-08-25 02:05:11 -04:00
README.md Fix README install instructions (not published to any registry) 2026-08-25 02:11:06 -04:00
tsconfig.base.json Add library exports, dual ESM/CJS build, comprehensive README 2026-08-25 02:05:11 -04:00
tsconfig.cjs.json Add library exports, dual ESM/CJS build, comprehensive README 2026-08-25 02:05:11 -04:00
tsconfig.esm.json Add library exports, dual ESM/CJS build, comprehensive README 2026-08-25 02:05:11 -04:00

🔤 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.

CI npm-free types license


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