Skip to content
Convert strings between camelCase, PascalCase, Title Case, snake_case and more
TypeScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode
test
vendor
.gitignore
.travis.yml
CHANGELOG.md
LICENSE
README.md
camelCase.ts
clearCase.ts
constantCase.ts
dotCase.ts
headerCase.ts
lowerCase.ts
lowerFirstCase.ts
mod.ts
noCase.ts
normalCase.ts
paramCase.ts
pascalCase.ts
pathCase.ts
sentenceCase.ts
snakeCase.ts
swapCase.ts
titleCase.ts
types.ts
upperCase.ts
upperFirstCase.ts

README.md

Change Case

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

All methods support Unicode (non-ASCII characters) and non-string entities, such as objects with a toString property, numbers and booleans. Empty values (null and undefined) will result in an empty string.

Source code based on blakeembrey/change-case with TypeScript.

Usage

import { camelCase } from "https://deno.land/x/case/mod.ts";
camelCase("test string");
// => 'testString'

or

import camelCase from "https://deno.land/x/case/camelCase.ts";
camelCase("test string");
// => 'testString'

Available methods (short-hand shown below, long-hand available in examples):

All methods accept two arguments, the string to change case and an optional locale.

camelCase

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

camelCase("test string");
//=> "testString"

constantCase

Return as an upper case, underscore separated string.

constantCase("test string");
//=> "TEST_STRING"

dotCase

Return as a lower case, period separated string.

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

headerCase

Return as a title cased, dash separated string.

headerCase("test string");
//=> "Test-String"

lowerCase

Return the string in lower case.

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

lowerFirstCase

Return the string with the first character lower cased.

lowerFirstCase("TEST");
//=> "tEST"

normalCase

  • no
  • clear

Return the string without any casing (lower case, space separated).

normalCase("test string");
//=> "test string"

paramCase

Aliases

  • kebabCase
  • hyphenCase

Return as a lower case, dash separated string.

paramCase("test string");
//=> "test-string"

pascalCase

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

pascalCase("test string");
//=> "TestString"

pathCase

Return as a lower case, slash separated string.

pathCase("test string");
//=> "test/string"

sentenceCase

Return as a lower case, space separated string with the first letter upper case.

sentenceCase("testString");
//=> "Test string"

snakeCase

Return as a lower case, underscore separated string.

snakeCase("test string");
//=> "test_string"

swapCase

Return as a string with every character case reversed.

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

titleCase

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

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

upperCase

Return the string in upper case.

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

upperFirstCase

Return the string with the first character upper cased.

upperFirstCase("test");
//=> "Test"

Credits

License

deno-change-case is released under the MIT License. See the bundled LICENSE file for details.

You can’t perform that action at this time.