String.prototype.toString() returns this string’s primitive text (same API as MDN String.prototype.toString()). Learn how it unwraps new String(...) objects, how it matches valueOf(), why wrong this throws TypeError, five examples, and try-it labs.
01
Kind
Instance method
02
Returns
string primitive
03
Parameters
None
04
vs valueOf
Same result
05
Wrong this
TypeError
06
Baseline
Widely available
Fundamentals
Introduction
Almost every string you write is already a primitive ("like this". toString() still matters when you meet a Stringobject from new String(...), or when you want an explicit “give me the text” call.
For String values, this method overrides Object.prototype.toString. It returns the string itself (primitive) or the text wrapped by the object — the same behavior as valueOf().
💡
Beginner tip
Prefer string literals "hi" over new String("hi"). When you already have a primitive, toString() just returns that same text.
String.prototype.toString() is Baseline Widely available — part of the language from early editions and safe everywhere.
✓ Baseline · Widely available
String.toString()
Safe for production in browsers and runtimes (Node.js, Deno, Bun). Simple unwrap of String objects to primitives.
UniversalWidely available
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
toString()Excellent
Bottom line: Use String.toString() to get the primitive text from a string or String object. Use String(value) for general conversion, and Number.toString for numeric bases.
Wrap Up
Conclusion
String.prototype.toString() returns the underlying string text — especially useful when unwrapping new String(...). It matches valueOf(), takes no radix, and throws if this is not a string.
Use toString() to unwrap String objects when needed
Use String(x) for converting non-strings
Remember it equals valueOf() for String
Link learners to Number.toString for radix needs
❌ Don’t
Pass a radix to String.toString (not supported)
Expect coercion of numbers via this method
Confuse it with Object.prototype.toString
Override String.prototype.toString in production code
Assume wrappers and primitives compare equal with ===
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about String.toString()
Returns the string primitive — same as valueOf().
5
Core concepts
📝01
Returns
string primitive
API
🔢02
Parameters
none
Args
🔄03
valueOf
identical
Twin
❌04
Wrong this
TypeError
Limit
⚡05
Prefer
literals
Style
❓ Frequently Asked Questions
String.prototype.toString() returns the string primitive itself (for a string literal) or the string wrapped by a String object. It takes no arguments.
For String, they have the same implementation. Both return the underlying string text. Prefer either for unwrapping a String object; beginners often meet toString() first.
Rarely for string primitives — they are already strings. It is useful when you have a String object from new String(...) and want a primitive, or when documenting explicit conversion.
Calling String.prototype.toString with a non-string this (for example via call/apply on a number) throws TypeError. It does not coerce other types to string.
No. Number.toString() can take a radix (base 2–36). String.toString() has no radix — it only returns the string value.
No. It returns a string primitive. String objects and primitives are not mutated by the call.
Did you know?
String has no Symbol.toPrimitive. When a Stringobject is used where a string is expected (like a template literal), JavaScript calls toString(). A string primitive is already a string, so that call is skipped.