# `Capitalize<StringType>`

> The `Capitalize<StringType>` utility type in TypeScript converts the first character of a string literal type to uppercase.

## How do I capitalize a string literal type in TypeScript?

The intrinsic string manipulation type that converts the first character of a string literal type to uppercase. Often used to generate names like 'onClick' from 'click'.

- Topic: Utility Types
- Type: utility type

## Example

Wrong:

```ts
type Event = 'click' | 'focus';
type Handler = `on${Event}`; // 'onclick'
```

Right:

```ts
type Event = 'click' | 'focus';
type Handler = `on${Capitalize<Event>}`; // 'onClick'
```

`Capitalize` uppercases the first letter, giving camelCase handler names like 'onClick'.

## Key points

- The runtime value is also transformed, e.g. with `toUpperCase()`, since the type alone does not change the string.
- The input is a string literal or template literal type, a plain `string` stays `string`.

## Interview questions

### Capitalize vs Uppercase: what is the difference?

`Capitalize` changes only the first character; `Uppercase` changes every character.

### Why does Capitalize`<K>` fail on keyof T?

Keys can be `string | number | symbol`. Use `Capitalize<string & K>` to keep only string keys.

## Related cards

- [`Uncapitalize<StringType>`](https://wonderium.dev/ts/uncapitalize.md)
- [`Uppercase<StringType>`](https://wonderium.dev/ts/uppercase.md)
- [Template Literal Types](https://wonderium.dev/ts/template-literal-types.md)
- [Mapped Types](https://wonderium.dev/ts/mapped-types.md)
- [Literal Types](https://wonderium.dev/ts/literal-types.md)

---

- Level: [TypeScript](https://wonderium.dev/ts.md)
- HTML version: https://wonderium.dev/ts/capitalize
- Last updated: 2026-11-25
