A lightweight and feature-rich utility library for bidirectional conversion between camelCase and snake_case.
-
Bidirectional Conversion: Supports seamless conversion between
camelCase
↔snake_case
. - Flexible Configuration: Customize behavior with options (e.g., preserve consecutive uppercase letters, custom separators).
- Unicode Support: Compatible with multilingual characters (e.g., Greek letters, Japanese).
- Zero Dependencies: Only ~2KB (gzipped).
For detailed usage instructions and API references, please visit the official documentation:
import { camelize, decamelize } from 'camel-kit';
// Snake to Camel
console.log(camelize('snake_case_example')); // Output: snakeCaseExample
// Camel to Snake
console.log(decamelize('camelCaseExample')); // Output: camel_case_example
// Convert to PascalCase (uppercase first letter)
console.log(camelize('hello_world', { pascalCase: true })); // Output: HelloWorld
// Preserve consecutive uppercase letters (e.g., 'HTTPRequest' → 'http_Request')
console.log(camelize('HTTP_Request', { preserveConsecutiveUppercase: true })); // Output: hTTP_Request
// Custom separator (e.g., kebab-case)
console.log(decamelize('camelCase', { separator: '-' })); // Output: camel-case
// Preserve consecutive uppercase letters (e.g., 'FOOBar' → 'FOO_Bar')
console.log(decamelize('FOOBar', { preserveConsecutiveUppercase: true })); // Output: FOO_Bar
console.log(camelize(['hello', 'world'])); // Output: helloWorld
console.log(decamelize('helloWorld', { separator: '_' })); // Output: hello_world
// Process multilingual characters
console.log(camelize('üser_näme')); // Output: üserNäme
console.log(decamelize('üserNäme')); // Output: üser_näme
We welcome contributions from the community! If you find a bug or want to suggest an improvement, feel free to open an issue or submit a pull request.
- Fork the repository.
- Create a new branch for your changes.
- Submit a pull request with a clear description of your changes.
This project is licensed under the MIT License.
Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ |