Skip to content

CaseConversion

Capitalizes the first letter of a word in a string.

  • str: string - The input string.
  • locales?: Intl.LocalesArgument - BCP 47 language tag(s) for case conversion (e.g., ‘en-US’).

The string with the first letter capitalized.

Definition
function capitalizeInitial(str: string, locales?: Intl.LocalesArgument): string
Examples
capitalizeInitial('hello') // 'Hello'
capitalizeInitial(':> hello') // ':> Hello'

Capitalizes the first letter of each word in a given string.

  • str: string - The input string.
  • locales?: Intl.LocalesArgument - BCP 47 language tag(s) for case conversion (e.g., ‘en-US’).

The input string with the first letter of each word capitalized.

Definition
function capitalizeWords(str: string, locales?: Intl.LocalesArgument): string
Examples
capitalizeWords('hello world') // 'Hello World'
capitalizeWords('This was your big idea, remember?') // 'This Was Your Big Idea, Remember?'

Converts a string to snake_case format.

  • str: string - The input string.
  • inWords: boolean If true, converts numbers to words in snake_case format.
  • locales?: Intl.LocalesArgument - BCP 47 language tag(s) for case conversion (e.g., ‘en-US’).

The string converted to snake_case format.

Definition
function snakeCase(str: string, inWords?: boolean, locales?: Intl.LocalesArgument): string
Examples
snakeCase('hello WorLd') // 'hello_world'
snakeCase('from-kebab-case') // 'from_kebab_case'
snakeCase('snake Case With Numbers123', true) // 'snake_case_with_numbers_one_two_three'

Converts a string to kebab-case format.

  • str: string - The input string.
  • inWords: boolean If true, converts numbers to words in kebab-case format.
  • locales?: Intl.LocalesArgument - BCP 47 language tag(s) for case conversion (e.g., ‘en-US’).

The string converted to kebab-case format.

Definition
function kebabCase(str: string, inWords?: boolean, locales?: Intl.LocalesArgument): string
Examples
kebabCase('h3llo WoRld') // 'h3llo-world'
kebabCase('from_snake_case') // 'from-snake-case'
kebabCase('kebab Case With Numbers123', true) // 'kebab-case-with-numbers-one-two-three'

Converts a string to camelCase format.

  • str: string - The input string.
  • locales?: Intl.LocalesArgument - BCP 47 language tag(s) for case conversion (e.g., ‘en-US’).

The string converted to camelCase format.

Definition
function camelCase(str: string, locales?: Intl.LocalesArgument): string
Examples
camelCase('hello WoRld') // 'helloWorld'
camelCase('Test CaSe ExamplE') // 'testCaseExample'
camelCase('camel Case With Numbers123') // 'camelCaseWithNumbers'

Converts a string to PascalCase format.

  • str: string - The input string.
  • locales?: Intl.LocalesArgument - BCP 47 language tag(s) for case conversion (e.g., ‘en-US’).

The string converted to PascalCase format.

Definition
function PascalCase(str: string, locales?: Intl.LocalesArgument): string
Examples
pascalCase('hello WoRld') // 'HelloWorld'
pascalCase('Test CaSe ExamplE') // 'TestCaseExample'
pascalCase('pasCal Case With Numbers123') // 'PascalCaseWithNumbers'