Toolbox-XToolbox-X

Capitalize a String

Converts the first letter of a given string to uppercase while keeping the rest lowercase (unless otherwise specified).

capitalizeString

The capitalizeString function converts the first letter of a given string to uppercase while keeping the rest lowercase. It provides options to capitalize each word's first letter, capitalize the entire string, or preserve the casing of the rest of the string.

Function Signature

function capitalizeString(string: string, options?: CapitalizeOptions): string

Parameters

  • string (string): The string to capitalize.
  • options (CapitalizeOptions, optional): Customization options:
    • capitalizeEachFirst (boolean): Capitalizes the first letter of each word. Defaults to false.
    • capitalizeAll (boolean): Converts the entire string to uppercase. Defaults to false.
    • lowerCaseRest (boolean): Ensures all characters except the first are lowercase. Defaults to true.

Return Value

  • string: The capitalized string.

Example Usage

playground.ts

Types

CapitalizeOptions

interface CapitalizeOptions {
  capitalizeEachFirst?: boolean;
  capitalizeAll?: boolean;
  lowerCaseRest?: boolean;
}

See Also

Last updated: Sun, Jun 14, 2026 07:06:16AM (UTC)

On this page