Intrinsic String Manipulation Types
Use Uppercase, Lowercase, Capitalize, and Uncapitalize.
Intrinsic String Manipulation Types is a free TypeScript Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the TypeScript Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Built-In String Transformers
TypeScript ships four intrinsic string manipulation types: Uppercase, Lowercase, Capitalize, and Uncapitalize. They transform string literal types at compile time, with no runtime cost.
Uppercase
Uppercase<S> converts every character of a string literal type to upper case. The literal 'hello' becomes the type 'HELLO'.
type Loud = Uppercase<"hello"> // "HELLO"
const x: Loud = "HELLO"
console.log(x)Lowercase
Lowercase<S> does the reverse, lowering every character. 'HELLO' becomes 'hello'.
type Quiet = Lowercase<"HELLO"> // "hello"
const x: Quiet = "hello"
console.log(x)Capitalize
Capitalize<S> uppercases only the first character, leaving the rest untouched. 'name' becomes 'Name'.
type Title = Capitalize<"name"> // "Name"
const x: Title = "Name"
console.log(x)Uncapitalize
Uncapitalize<S> lowercases only the first character. 'Name' becomes 'name' — handy for converting PascalCase keys to camelCase.
type Camel = Uncapitalize<"Name"> // "name"
const x: Camel = "name"
console.log(x)Transforming a Union
Apply an intrinsic type to a union and it transforms each member. Uppercase of 'a' | 'b' yields 'A' | 'B'.
type Keys = "id" | "name"
type Upper = Uppercase<Keys> // "ID" | "NAME"
const k: Upper = "ID"
console.log(k)Combining With Template Literals
The intrinsics are most powerful inside template literal types. A template that prefixes get before Capitalize of a field builds getter names like a getter for the name field.
type Field = "name" | "age"
// template: get + Capitalize<Field> => "getName" | "getAge"
const g: "getName" | "getAge" = "getName"
console.log(g)Building Key Names in Mapped Types
Inside a mapped type's key remapping, intrinsics generate transformed property names — for instance, turning each property into a capitalized handler key.
type Events = "click" | "drag"
// { [E in Events as on + Capitalize<E>]: () => void }
// produces keys onClick and onDrag
const handlers: { onClick: () => void } = { onClick: () => {} }
console.log(typeof handlers.onClick)Chaining Intrinsics
You can nest intrinsics to compose transformations — for example uppercasing then it would conflict, so a common combo is Capitalize of a Lowercase string to normalize casing.
type Normalized = Capitalize<Lowercase<"hELLO">> // "Hello"
const x: Normalized = "Hello"
console.log(x)Compile-Time Only
These types do not exist at runtime. To transform an actual string value you still call methods like toUpperCase(); the intrinsics only shape the static types.
function shout<S extends string>(s: S): Uppercase<S> {
return s.toUpperCase() as Uppercase<S>
}
console.log(shout("hi")) // HI, typed as "HI"
Practical Uses
Use the intrinsics to derive constant names, event keys, getter and setter names, and to normalize casing of literal-typed config keys — all checked by the compiler.
type Action = "add" | "remove"
type ActionType = Uppercase<Action> // "ADD" | "REMOVE"
const a: ActionType = "ADD"
console.log(a)Quick Check
Test your understanding of intrinsic string types.
Recap
The intrinsic types Uppercase, Lowercase, Capitalize, and Uncapitalize transform string literal types at compile time, distributing over unions and composing with template literal and mapped types to build key and handler names. They have no runtime behavior — use real string methods for runtime transformation while these shape the static types.
Frequently asked questions
Is the “Intrinsic String Manipulation Types” lesson free?
Yes — the full text of “Intrinsic String Manipulation Types” is free to read here on the web, and the TypeScript Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the TypeScript Academy course, upgrade to CoddyKit PRO.
What will I learn in “Intrinsic String Manipulation Types”?
Use Uppercase, Lowercase, Capitalize, and Uncapitalize. You practise TypeScript Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start TypeScript Academy?
No prior experience is required. TypeScript Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Intrinsic String Manipulation Types” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this TypeScript Academy lesson?
Yes. Every TypeScript Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Template Literal Type Basics
- Modeling Structured Strings
- String Unions and Autocomplete
- Intrinsic String Manipulation Types