The Four Built-In String Manipulation Types
What You'll Learn
You'll discover TypeScript's four intrinsic string transformation utilities that automatically convert the case of string literal types at the type level.
The Core Idea
TypeScript provides four special intrinsic types that transform string literal types by changing their capitalization. These are built directly into the compiler, not implemented with regular mapped or conditional types:
Uppercase<S>— Converts all characters to uppercaseLowercase<S>— Converts all characters to lowercaseCapitalize<S>— Converts only the first character to uppercaseUncapitalize<S>— Converts only the first character to lowercase
Think of these as type-level string methods. Just like JavaScript's toUpperCase() or toLowerCase() work at runtime, these utilities work at compile-time on your types.
How They Work
type Greeting = "hello world";
type Shouting = Uppercase<Greeting>;
// type Shouting = "HELLO WORLD"
type Whisper = Lowercase<Greeting>;
// type Whisper = "hello world"
type Proper = Capitalize<Greeting>;
// type Proper = "Hello world"
type Casual = Uncapitalize<"Hello World">;
// type Casual = "hello World"
These transformations distribute over union types automatically:
type HttpMethod = "get" | "post" | "put" | "delete";
type HttpMethodUpper = Uppercase<HttpMethod>;
// type HttpMethodUpper = "GET" | "POST" | "PUT" | "DELETE"
Why This Matters
Combined with template literal types, these intrinsics unlock powerful type-safe string patterns. You can enforce consistent naming conventions, generate related type variations, or create case-insensitive type mappings—all without runtime code.
They're particularly valuable when working with APIs, database columns, or event names that follow specific casing conventions.
Key Takeaway: TypeScript's Uppercase, Lowercase, Capitalize, and Uncapitalize are compiler-intrinsic types that transform string literal types' capitalization, enabling sophisticated type-level string manipulation without runtime overhead.