toString() turns a Boolean into text. A Boolean is a value with only two choices, true or false. The result is the string "true" or the string "false", always in lowercase. The Boolean itself is a primitive, which means a plain value such as true, 42, or "hi" and not an object. Unlike Number’s toString(), this method has no parameters: there is no radix, because there is only one way to write a Boolean as text. The text is useful for labels, logs, URLs, and CSV files. It is not a Boolean any more, so the text "false" is truthy.
Remember
true.toString(); // "true"
(false).toString(); // "false"
true.toString(2); // "true" (the argument is ignored)
new Boolean(false).toString(); // "false"
String(true); // "true"
Boolean("false"); // true (the text "false" is truthy!)
"false" === "true"; // false (compare text like this)
Boolean.prototype.toString.call("true"); // TypeError
Syntax
Call it on a Boolean value, in parentheses or right after a literal. It takes no arguments.
JavaScript
boolean.toString()
Call
What it does
true.toString()
Gives the text "true". Writing a dot right after true or false is fine, because a Boolean literal has no decimal point.
isActive.toString()
Gives "true" or "false" depending on the variable. It throws a TypeError if the variable holds null or undefined.
new Boolean(false).toString()
A Boolean object gives the text of the value inside it: "false", even though the object itself is truthy.
true.toString(2)
Still gives "true". A radix works for numbers, but Boolean ignores any argument you pass.
String(isActive)
The same text, and safe for null and undefined: String(null) is "null" instead of an error.
Part of JavaScript since its first versions. JavaScript calls toString() for you when a Boolean meets a string: "on: " + true, a template literal, and [true, false].join() all give the text. Boolean.prototype is itself a Boolean object whose value is false, so Boolean.prototype.toString() returns "false".
Library declarations
JavaScript
boolean.toString() // returns "true" or "false"
// No parameters: extra arguments are ignored.
// "this" must be a Boolean or a Boolean object,
// anything else throws a TypeError.
Parameters
Parameter
Description
(none)
toString() takes no parameters. Any argument is ignored, so true.toString(2) and true.toString(16) both return "true". This is different from Number.prototype.toString(radix).
Return Value
Return Value
Description
String
Exactly "true" or "false", in lowercase. It is never "True", "1", or "yes". To go back to a Boolean, write text === "true".
JavaScript Examples
Example 1 — Turn a Flag Into a Status Label
A flag is a Boolean variable such as isActive. Its text can be used as a key to look up a friendly label. The extra argument in the last line is ignored.
The flag becomes a string.isActive.toString() gives "true". The first typeof check proves the result is a string, and "true" has 4 characters.
The text is the lookup key. Object keys are text, so labels["true"] finds "Active". A comparison such as 3 > 5 gives false, and its text "false" finds "Inactive".
The radix is ignored.toString(2) would give binary digits for a number. A Boolean has no digits to change, so the argument is ignored and the answer is still "true".
Example 2 — Build a Query String and a List of Flags
URLs, CSV files, and logs need text, not Booleans. Join the flags into a query string, print a list, and see why String() is the safe choice for missing values.
?active=true&admin=false
true,false,true
yes no yes
null
TypeError
How It Works
Each flag becomes key=text. The loop turns true and false into "true" and "false" and joins the pairs with &, which is the format of a URL query string.
Lists are joined with text too.join(",") calls toString() on every item behind the scenes. For friendlier words, Number(true) is 1 and Number(false) is 0, so ["no", "yes"][Number(f)] picks the right word.
String() does not crash.String(null) is the text "null". Calling .toString() on null has nothing to run on, so it throws a TypeError.
Example 3 — Read a Boolean Back From Text
Saved settings often come back as strings. This example shows why Boolean("false") is wrong and what to write instead.
The saved value is text.(false).toString() gives "false", a string with five letters. It looks like a Boolean when printed, but typeof says string.
Any non-empty string is truthy.Boolean(saved) is true, so an if on this text would run. Comparing with === "true" gives the correct false, and JSON.parse("false") also gives a real false.
The method only accepts Booleans..call("true") runs the method on a string. A string is not a Boolean or a Boolean object, so JavaScript throws a TypeError.
Compatibility
Browser & Runtime Support
Boolean.prototype.toString() has been part of JavaScript since the first language versions, so every browser and runtime has it.
✓ Baseline · Long-standing
Boolean.prototype.toString()
Works the same in all browsers and in every version of Node.js, Deno, and Bun. The result is always the lowercase text true or false.
100%Browser support
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium
Full support
OperaAll versions
Full support
Samsung InternetAll versions · Android
Full support
Internet ExplorerAll versions
Full support
Node.jsAll versions · checked on Node 24
Supported
DenoAll releases
Supported
BunAll releases
Supported
Boolean.prototype.toString()Excellent
Bottom line: Use it freely anywhere. Only the wording of the TypeError messages (for a missing value or a wrong this) differs between engines, so check e.name instead of the message.
Frequently Asked Questions
Call flag.toString() or String(flag). Both give "true" or "false". Template literals and joining with a string do the same. When the flag sits inside an object, JSON.stringify() also writes it as true or false.
No. A Boolean has no digits to change, so the argument is ignored: true.toString(2) is still "true". Only Number and BigInt use a radix.
Because "false" is a non-empty string, and every non-empty string is truthy. To read a saved flag, compare it: text === "true". For JSON text, JSON.parse("false") gives the real false.
null and undefined have no methods, so calling .toString() on them throws a TypeError. String(value) works for any value and gives "null" or "undefined" instead.
It returns "false". Boolean.prototype is itself a Boolean object whose value is false, so the method works on it. This is a curiosity: in real code you call toString() on your own values.