QuickSnip LogoA light blue logo with a thunderbolt in bracketsQuickSnip

Capitalize

Verified

Uppercases the first character of a string.

  • string
  • capitalize

Install

npx shadcn@latest add https://quicksnip.dev/r/capitalize.json

Code

/** Uppercases the first character of a string and leaves the rest untouched. */
export function capitalize(input: string): string {
  return input.charAt(0).toUpperCase() + input.slice(1);
}

Usage

capitalize("hello world"); // "Hello world"