shadimage
utilcn
libcapitalize-allsource: ok · hit

Capitalize All

Capitalize the first letter of every word in a string.

npx shadcn add "https://utilcn.dev/r/capitalize-all.json"
free

Interaction

text-animation

Tags auto-generated by rules on 9/24/2026 — empty means no evidence, not lack of support.

Files1 · source cached 10/10/2026, 7:09:38 PM

registry/default/strings/capitalize-all.ts
/**
 * Capitalizes the first letter of every word in a string.
 *
 * @param str - The input string.
 * @returns The title-cased string.
 *
 * @example
 * capitalizeAll("hello world"); // "Hello World"
 */
export function capitalizeAll(str: string): string {
  return str.replace(
    /(^|\s)(\S)/g,
    (_, space, char) => space + char.toUpperCase(),
  );
}

More from utilcn

Browse all components in this library →