@free-tools/case-convert (2.0.1)

Published 2026-08-25 19:27:51 +00:00 by gautham

Installation

@free-tools:registry=
npm install @free-tools/case-convert@2.0.1
"@free-tools/case-convert": "2.0.1"

About this package

🔤 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

Dependencies

Development dependencies

ID Version
@types/node ^20.14.0
@typescript-eslint/eslint-plugin ^7.18.0
@typescript-eslint/parser ^7.18.0
eslint ^8.57.0
typescript ^5.5.4

Keywords

case camelcase snakecase kebabcase pascalcase cli typescript
Details
npm
2026-08-25 19:27:51 +00:00
1
MIT
latest
2.9 KiB
Assets (1)
Versions (1) View all
2.0.1 2026-08-25