change-case NPM package includes many text conversion methods for most common cases: camel case, capital case, constant case, dot case, header case, no case, param case, pascal case, path case, sentence case, and snake case. It’s very easy to use, see example:

const changeCase = require('change-case')

const input = 'An_Example string-with.mixed CASES 11.12-2020.. @ #$ %^  & * ('

console.log(changeCase.camelCase(input))
// => anExampleStringWithMixedCases_11_12_2020

console.log(changeCase.capitalCase(input))
// => An Example String With Mixed Cases 11 12 2020

console.log(changeCase.constantCase(input))
// => AN_EXAMPLE_STRING_WITH_MIXED_CASES_11_12_2020

console.log(changeCase.dotCase(input))
// => an.example.string.with.mixed.cases.11.12.2020

console.log(changeCase.headerCase(input))
// => An-Example-String-With-Mixed-Cases-11-12-2020

console.log(changeCase.noCase(input))
// => an example string with mixed cases 11 12 2020

console.log(changeCase.paramCase(input))
// => an-example-string-with-mixed-cases-11-12-2020

console.log(changeCase.pascalCase(input))
// => AnExampleStringWithMixedCases_11_12_2020

console.log(changeCase.pathCase(input))
// => an/example/string/with/mixed/cases/11/12/2020

console.log(changeCase.sentenceCase(input))
// => An example string with mixed cases 11 12 2020

console.log(changeCase.snakeCase(input))
// => an_example_string_with_mixed_cases_11_12_2020
Share This