
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
convert-cases
Advanced tools
A minimal utility function library that converts camelCase to snake_case and snake_case to camelCase.
Utilities to convert camelCase to sanke_case and snake_case to camelCase.
Nested object keys can also be converted together.
// use npm
$ npm i convert-cases -S
// use Yarn
$ yarn add convert-cases
4 functions are provided.
deeplyCamelize : Convert all nested object keys to camelCase.deeplySnakize : Convert all nested object keys to snake_case.snakeToCamel : Converts single string to camelCase.camelToSnake : Converts single string to snake_case.import { deeplyCamelize } from 'convert-cases'
const obj = {
test_case: '1',
array: [
{ array_case: 1 },
{ array_case: 2 },
],
}
deeplyCamelize(obj) // { testCase: '1', array: [ { arrayCase: 1 }, { arrayCase: 2 } ] }
You can specify the input and output types using generics:
deeplyCamelize<BeforeObjType, AfterObjType>(obj)
However, both type parameters are optional. If omitted, the input type will be inferred from the argument, and the output will be inferred as the camelCase equivalent of the input type:
const result = deeplyCamelize({
test_case: '1',
array: [
{ array_case: 1 },
{ array_case: 2 },
],
})
// inferred:
// {
// testCase: '1',
// array: [
// { arrayCase: 1 },
// { arrayCase: 2 },
// ],
// }
The type transformation is recursive and accurately reflects the actual runtime output.
import { deeplySnakize } from 'convert-cases'
const obj = {
testCase: '1',
array: [
{ arrayCase: 1 },
{ arrayCase: 2 },
],
}
deeplySnakize(obj) // { test_case: '1', array: [ { array_case: 1 }, { array_case: 2 } ] }
As with deeplyCamelize, you can provide both input and output types using generics:
deeplySnakize<BeforeObjType, AfterObjType>(obj)
But both type parameters are optional. If omitted, the input type is inferred automatically, and the output type will be inferred as the snake_case equivalent:
const result = deeplySnakize({
testCase: '1',
array: [
{ arrayCase: 1 },
{ arrayCase: 2 },
],
})
// inferred:
// {
// test_case: '1',
// array: [
// { array_case: 1 },
// { array_case: 2 },
// ],
// }
import { snakeToCamel } from 'convert-cases'
snakeToCamel('snake_case') // 'snakeCase'
import { camelToSnake } from 'convert-cases'
snakeToCamel('camelCase') // 'camel_case'
FAQs
A minimal utility function library that converts camelCase to snake_case and snake_case to camelCase.
We found that convert-cases demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.