If you’ve tried to convert boolean to string in TypeScript by calling toString() on an API field, you’ve probably seen Cannot read properties of undefined. The field wasn’t false; it was missing.
The safe answer is String(value): it returns "true" or "false" for real booleans and never throws on undefined.
In this tutorial, I’ll walk you through four ways to convert boolean to string in TypeScript, including Yes/No labels. I compiled every example with TypeScript 7.0.2 and Node.js v22.22.2 in strict mode.
The Sample Order Object with Boolean Flags
Every example uses one order from a US online store. Megan Bowen’s order is paid, not shipped, and has no gift-wrap answer:
type Order = {
customer: string;
total: number;
isPaid: boolean;
isShipped: boolean;
giftWrap?: boolean;
};
const order: Order = {
customer: "Megan Bowen", total: 149.99,
isPaid: true, isShipped: false,
};
The optional giftWrap is undefined here, and that’s where conversions break. See checking for undefined in TypeScript for the basics.
Method 1: Convert a Boolean to a String with String() (Recommended)
Use String() whenever a value might be missing. Same order object, three flags:
// order = the sample object above
const paid: string = String(order.isPaid);
const shipped: string = String(order.isShipped);
const gift: string = String(order.giftWrap);
console.log(paid, typeof paid);
console.log(shipped, typeof shipped);
console.log(gift, typeof gift);
Output:
true string
false string
undefined string
All three print as strings: true, false and undefined.

How does this code work?
String() without new is a plain conversion function, so its return type is always string.
Users shouldn’t see "undefined", though; Method 4 fixes that.
It’s the same tool I use for numbers; see converting a number to a string in TypeScript.
Method 2: Use toString() on a Boolean Value
toString() reads well when the value is surely a boolean. Here’s the paid flag, plus an API record that skipped the field:
// order = the sample object above
console.log(order.isPaid.toString());
console.log(order.giftWrap?.toString() ?? "not set");
const fromApi = JSON.parse('{"customer":"Alex Wilber"}') as Order;
try {
console.log(fromApi.isPaid.toString());
} catch (err) {
console.log("TypeError:", (err as Error).message);
}
console.log("String():", String(fromApi.isPaid));
Output:
true
not set
TypeError: Cannot read properties of undefined (reading 'toString')
String(): undefined
You get true and not set, then a TypeError for the API record, while String() prints undefined.

toString() crashes on the field JSON never sent.How does this code work?
Strict mode blocks order.giftWrap.toString() because it’s possibly undefined. ?. skips the call and ?? adds a fallback.
The as Order cast is the catch: the compiler trusts the JSON, so nothing warns you. More on ?? in my guide to the double question mark operator in TypeScript.
Method 3: Template Literals and String Concatenation
For a sentence or log line, drop the boolean into a template literal. Same order object again:
// order = the sample object above
const line = `Paid: ${order.isPaid}, shipped: ${order.isShipped}`;
console.log(line);
console.log("Gift wrap: " + order.giftWrap);
Output:
Paid: true, shipped: false
Gift wrap: undefined
You get Paid: true, shipped: false, then Gift wrap: undefined.
How does this code work?
A template literal, like + with a string, uses the same conversion as String(), so it never throws.
For longer messages, see appending to a string in TypeScript.
Method 4: Turn a Boolean into Custom Labels like Yes/No
Users don’t want to read true. A ternary or lookup map turns the same order object’s flags into words:
// order = the sample object above
const yesNo = (b: boolean): string => (b ? "Yes" : "No");
const STATUS: Record<`${boolean}`, string> = {
true: "Paid",
false: "Unpaid",
};
console.log(`${order.customer}: $${order.total.toFixed(2)}`);
console.log("Paid:", yesNo(order.isPaid));
console.log("Shipped:", yesNo(order.isShipped));
console.log("Gift wrap:", yesNo(order.giftWrap ?? false));
console.log("Status:", STATUS[`${order.isPaid}`]);
Output:
Megan Bowen: $149.99
Paid: Yes
Shipped: No
Gift wrap: No
Status: Paid
That prints Megan Bowen: $149.99, Paid: Yes, Shipped: No, Gift wrap: No and Status: Paid.

How does this code work?
yesNo() is a one-line ternary, and giftWrap ?? false turns the missing answer into No.
Record<`${boolean}`, string> requires both keys, so a missing label won’t compile. The boolean vs Boolean types in TypeScript guide explains why lowercase boolean is right here.
Pro Tip: keep every label in one map like STATUS.
Why Does TypeScript Say Type ‘boolean’ Is Not Assignable to Type ‘string’?
TypeScript never converts a boolean for you. Assign one to a string variable and the compiler stops:
const isPaid: boolean = true;
const label: string = isPaid;
Output:
bool_assign.ts(3,7): error TS2322: Type 'boolean' is not assignable to type 'string'.

Fix it with String(isPaid) or a label helper. To check a value’s type first, see checking the type of a variable in TypeScript.
Which Boolean to String Method Should You Use?
| Method | Best for | Missing value |
|---|---|---|
String(value) | Default choice, unknown data | “undefined”, no crash |
value.toString() | Values you know are booleans | Throws TypeError |
| Template literal | Messages and log lines | “undefined”, no crash |
| Ternary / lookup map | Text users read | Your fallback label |
My pick: String() in code, labels on screen.
Things to Keep in Mind When Converting Booleans
- Optional fields are
undefined, notfalse; add?? falsewhen needed. - Going the other way,
Boolean("false")istrue; use the steps in converting a string to a boolean in TypeScript. - Numbers aren’t booleans: convert a number to a boolean before labeling 0/1 flags.
A few more TypeScript string guides worth bookmarking:
- Convert a date to a string in TypeScript
- Convert a string to an enum in TypeScript
- Compare strings in TypeScript
- Check if a string is empty in TypeScript
Frequently Asked Questions
How do I convert a boolean to a string in TypeScript?
Use String(value); it never throws on undefined.
What’s the difference between String() and toString() for booleans?
Same text for real booleans, but toString() throws a TypeError on undefined or null.
How do I show Yes or No instead of true or false?
Use b ? "Yes" : "No" or a Record lookup map.
Why is my boolean not assignable to type string?
TypeScript won’t convert it for you; wrap it in String() first.
Does JSON.stringify() convert a boolean to a string?
Yes, but undefined returns undefined, not a string.