change-case

Convert a string between camelCase, PascalCase, Title Case, snake_case and more.

npm install change-case
27 downloads in the last day
204 downloads in the last week
1 190 downloads in the last month

change-case

Quickly convert strings between camelCase, PascalCase, Title Case, snake_case, lowercase, UPPERCASE, CONSTANT_CASE and more.

Installation

npm install change-case --save

Usage

var changeCase = require('change-case');
//=> { isUpperCase: [Function], ... }

isUpperCase changeCase.isUpperCase(string)

Return a boolean indicating the string is upper cased.

changeCase.isUpperCase('test string');
//=> false

isLowerCase changeCase.isLowerCase(string)

Return a boolean indicating the string is lower cased.

changeCase.isLowerCase('test string');
//=> true

upperCase changeCase.upperCase(string)

Return an upper cased string.

changeCase.upperCase('test string');
//=> "TEST STRING"

lowerCase changeCase.lowerCase(string)

Return a lower cased string.

changeCase.lowerCase('TEST STRING');
//=> "test string"

titleCase changeCase.titleCase(string)

Return a space separated string with the first character of every word upper cased.

changeCase.titleCase('a simple test');
//=> "A Simple Test"

sentenceCase changeCase.sentenceCase(string)

Return a lower cased, space separated string.

changeCase.sentenceCase('testString');
//=> "test string"

camelCase changeCase.camelCase(string)

Return a string with the separators denoted by having the next letter capitalized.

changeCase.camelCase('test string');
//=> "testString"

pascalCase changeCase.pascalCase(string)

Return a string denoted in the same fashion as camelCase, but with the first letter also capitalized.

changeCase.pascalCase('test string');
//=> "TestString"

snakeCase changeCase.snakeCase(string)

Return a lower cased, space separated string.

changeCase.snakeCase('test string');
--> "test_string"

paramCase changeCase.paramCase(string)

Return a lower cased, dash separated string.

changeCase.paramCase('test string');
//=> "test-case"

dotCase changeCase.dotCase(string)

Return a lower cased, period separated string.

changeCase.dotCase('test string');
//=> "test.string"

pathCase changeCase.pathCase(string)

Return a lower cased, slash separated string.

changeCase.pathCase('test string');
//=> "test/string"

constantCase changeCase.constantCase(string)

Return an upper cased, underscore separated string.

changeCase.constantCase('test string');
//=> "TEST_STRING"

swapCase changeCase.swapCase(string)

Return a string with lower case characters upper cased and upper case character lower cased.

changeCase.swapCase('Test String');
//=> "tEST sTRING"

License

MIT

npm loves you