string-manipulation
Lowercase<S>
Intrinsic string type manipulator that converts each character of literal S to lowercase. Available since TS 4.1 and evaluated by the compiler with no runtime cost.
type Lowercase<S extends string> = intrinsic Usage patterns
| Pattern | Purpose |
|---|---|
| Lowercase<'HELLO'> | Basic lowercase transform |
| Lowercase<HTTPMethod> | Normalize a union of literal cases |
| Lowercase<S> extends S ? true : false | Test whether a literal is already lowercase |
| Uppercase<Lowercase<S>> | Two-step normalize/loudify |
Examples
type L = Lowercase<'WORLD'>; Result: 'world'
type HTTPMethod = 'GET' | 'POST' | 'PUT';
type Method = Lowercase<HTTPMethod>; Result: 'get' | 'post' | 'put' — distributes over unions
type Path<T extends string> = `/${Lowercase<T>}`;
type P = Path<'API'>; // '/api' Building URL patterns via template literal types
type S = Lowercase<string>; Result: string when the input is not a literal
Gotcha
Only literal string types are transformed — a bare `string` stays `string`. Emits no runtime code, so pair with String.prototype.toLowerCase() for actual value conversion.
Related utility types
Uppercase<S>
Compile-time intrinsic that converts a string literal type S to its uppercase form. Introduced in TS 4.1 alongside template literal types.
Capitalize<S>
Intrinsic string type utility that uppercases the first character of literal string S, leaving the rest unchanged. Enables typed camelCase-to-PascalCase and getter-name construction.
Uncapitalize<S>
Intrinsic type utility that lowercases the first character of literal S, leaving the rest unchanged. The inverse of Capitalize and widely used for PascalCase-to-camelCase mappings.
Record<K, V>
Creates an object type whose keys come from the union K and whose values all have type V. Useful for lookup tables, dictionaries, and enum-keyed maps.
← All TS utility types · TypeScript vs JavaScript · any vs unknown vs never