https://github.com/imcvampire/case-converter
transform object keys to different cases
https://github.com/imcvampire/case-converter
Last synced: 8 months ago
JSON representation
transform object keys to different cases
- Host: GitHub
- URL: https://github.com/imcvampire/case-converter
- Owner: imcvampire
- License: mit
- Created: 2017-10-21T09:22:48.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-06-28T05:47:20.000Z (about 4 years ago)
- Last Synced: 2025-06-30T05:05:27.393Z (about 1 year ago)
- Language: JavaScript
- Size: 206 KB
- Stars: 3
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# case-converter [](https://badge.fury.io/js/case-converter) [](https://travis-ci.org/travelperk/case-converter) [](https://codecov.io/gh/travelperk/case-converter) [](https://github.com/semantic-release/semantic-release)
A lightweight library that converts objects to different case conventions. Great for consuming APIs of services with different conventions, e.g. Python or Ruby.
[Demo](https://tonicdev.com/npm/case-converter)
## Features
- `toCamelCase`
- `toSnakeCase`
- `toKebabCase`
- `toPascalCase`
## Install
`npm install case-converter`
## Example:
```JavaScript
import { toCamelCase } from 'case-converter'
const snakeCase = {
an_object: {
'kebab-case': 'nested content',
nested_array: [{ an_object: 'something' }]
},
an_array: [
{ zero_index: 0 },
{ one_index: 1 }
]
}
const camelCase = toCamelCase(snakeCase);
console.log(camelCase)
/*
{
anObject: {
kebabCase: 'nested content',
nestedArray: [{ anObject: 'something' }]
},
anArray: [
{ zeroIndex: 0 },
{ oneIndex: 1 }
]
}
*/
```