Convert object keys to camel case using
camelcase
$ npm install camelcase-keys
const camelcaseKeys = require('camelcase-keys');
// Convert an object
camelcaseKeys({'foo-bar': true});
//=> {fooBar: true}
// Convert an array of objects
camelcaseKeys([{'foo-bar': true}, {'bar-foo': false}]);
//=> [{fooBar: true}, {barFoo: false}]
camelcaseKeys({'foo-bar': true, nested: {unicorn_rainbow: true}}, {deep: true});
//=> {fooBar: true, nested: {unicornRainbow: true}}
// Convert object keys to pascal case
camelcaseKeys({'foo-bar': true, nested: {unicorn_rainbow: true}}, {deep: true, pascalCase: true});
//=> {FooBar: true, Nested: {UnicornRainbow: true}}
const camelcaseKeys = require('camelcase-keys');
const argv = require('minimist')(process.argv.slice(2));
//=> {_: [], 'foo-bar': true}
camelcaseKeys(argv);
//=> {_: [], fooBar: true}
Type: object | object[]
An object or array of objects to camel-case.
Type: object
Type: Array<string | RegExp>
Default: []
Exclude keys from being camel-cased.
Type: boolean
Default: false
Recurse nested objects and objects in arrays.
Type: boolean
Default: false
Uppercase the first character as in bye-bye
→ ByeBye
.
Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.