Package Exports
- case-converters
- case-converters/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (case-converters) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
case-converters
⚠️ Not to be confused with the deprecated
case-converter
.
✅case-converters
is a modern, actively maintained package with full TypeScript support, robust object key transformation, and support for 15+ string casing styles.
case-converters
is a lightweight yet powerful utility to convert strings and object keys into a wide range of naming conventions — like camelCase
, PascalCase
, snake_case
, kebab-case
, Train-Case
, SpongeCase
, and more.
- ✔ Supports string and object key transformation
- ✔ Works with arrays of objects
- ✔ ESM & CommonJS compatible
- ✔ 100% written in TypeScript
📚 Table of Contents
- 📦 Supported Case Styles
- 🔧 Installation
- 🚀 Quick Usage
- 📘 API Reference
- 🌐 Live Demo
- 🔗 Links
- 📄 License
- 📬 Contact
📦 Supported Case Styles
camel
,pascal
,snake
,kebab
,constant
,dot
,path
,title
,sentence
,capital
,train
sponge
,swap
,upper
,lower
,no
,localeUpper
,localeLower
,lowerFirst
,upperFirst
- ... and more!
🔧 Installation
npm install case-converters
## 🚀 Quick Usage
### 🔹 String Case Conversion
#### CommonJS
```js
const { camel, upper } = require("case-converters");
console.log(camel("test string")); // testString
console.log(upper("test string")); // TEST STRING
ES Modules / TypeScript
import { Case } from "case-converters";
console.log(Case.camel("test string")); // testString
console.log(Case.upper("test string")); // TEST STRING
🔹 Object Key Case Conversion
Convert keys of an object (or array of objects):
const { objToCamel, objToPascal } = require("case-converters");
const input = [{ user_name: "Alice" }, { user_name: "Bob" }];
console.log(objToCamel(input));
console.log(objToPascal(input));
📘 API Reference
🔹 String Methods
You can use either the Case
class or direct function imports:
import {
camel,
capital,
constant,
dot,
no,
pascal,
path,
sentence,
snake,
train,
kebab,
sponge,
swap,
title,
upper,
localeUpper,
lower,
localeLower,
lowerFirst,
upperFirst,
isUpper,
isLower,
} from "case-converters";
const str = "test string";
camel(str);
pascal(str);
snake(str);
// ...
Or use the class style:
import { Case } from "case-converters";
Case.kebab(str);
Case.title(str);
🔹 Object Key Methods
Available functions:
objToCamel(obj)
objToPascal(obj)
objToSnake(obj)
objToKebab(obj)
objToConstant(obj)
objToCapital(obj)
objToTrain(obj)
objToTitle(obj)
objToSentence(obj)
objToDot(obj)
objToPath(obj)
objToNot(obj)
objToSponge(obj)
objToSwap(obj)
objToUpper(obj)
objToLower(obj)
Example:
const obj = { first_name: "John", last_name: "Doe" };
console.log(objToCamel(obj));
🌐 Live Demo
Try it online:
👉 StackBlitz Live Demo
🔗 Links
- 🧠 GitHub: cvchauhan/case-converter
- 📦 npm: case-converters
📄 License
ISC © Chirag Chauhan
📬 Contact
For questions, suggestions, or collaborations:
- GitHub: @cvchauhan
- Email: chiragvchauhan93@gmail.com