JavaScript Symbol toString() Method

Beginner
6 min read
Updated: Nov 2026
3 examples
Instance method

Definition

symbol.toString() returns the symbol as text. The text always has the form "Symbol(description)". For Symbol("userId") you get "Symbol(userId)", and for a symbol with no description you get "Symbol()".

You need this method because JavaScript does not turn a symbol into text on its own. Writing "Key: " + symbol or putting a symbol inside a template literal throws a TypeError. Calling toString() (or String(symbol)) is the safe way to print a symbol.

Remember
symbol.toString()

Symbol("id")      → "Symbol(id)"
Symbol()          → "Symbol()"

"a" + symbol      → TypeError
`${symbol}`       → TypeError
symbol.toString() → works
String(symbol)    → works
symbol.description → just "id"

Syntax

Call it on a symbol. It takes no arguments and returns a string.

JavaScript
const id = Symbol("userId");

console.log(id.toString());          // "Symbol(userId)"
console.log(String(id));             // "Symbol(userId)"
console.log(id.description);         // "userId"
CallWhat it does
symbol.toString()Return the text "Symbol(description)".
String(symbol)Gives the same text. This is the one conversion function that accepts a symbol.
symbol.descriptionReturn only the description, without the Symbol( ) part. It is undefined when there is none.
"" + symbolThrows a TypeError. Symbols are never joined to text by themselves.

A standard JavaScript method (ES2015) on every symbol, from Symbol.prototype. No import required. Siblings: Symbol.for(), Symbol.keyFor(), valueOf(), [Symbol.toPrimitive]().

Library declarations
JavaScript
// ECMAScript 2015 (ES6)
Symbol.prototype.toString()

// returns: a string like "Symbol(description)"
// throws : TypeError if called on something that is not a symbol

Parameters

ParameterDescription
(none)This method takes no parameters. Call it as symbol.toString().

Return Value

Return ValueDescription
stringThe text "Symbol(description)". If the symbol has no description, the text is "Symbol()".
TypeError (thrown)Only when the method is borrowed and called on a value that is not a symbol, for example Symbol.prototype.toString.call("text").

JavaScript Examples

Example 1 — Turn Symbols into Text

Print a named symbol, an unnamed one, a shared one, and a built-in one.

JavaScript
const named = Symbol("userId");
const empty = Symbol();
const shared = Symbol.for("app.theme");

console.log(named.toString());
console.log(empty.toString());
console.log(shared.toString());
console.log(Symbol.iterator.toString());
Try It Yourself

How It Works

  1. Named symbol. The description "userId" is put between the brackets: Symbol(userId).
  2. No description. Symbol() has nothing to show, so the brackets stay empty.
  3. Shared and built-in symbols. A shared symbol shows its key as the description. The built-in Symbol.iterator has the description "Symbol.iterator", so you see Symbol(Symbol.iterator).

Example 2 — See Why + and Template Literals Fail

Join a symbol to text with + and with a template literal, and then use the two safe ways. The catch block prints the error type only.

JavaScript
const id = Symbol("userId");

try {
  console.log("Joined: " + id);
} catch (err) {
  console.log("Plus operator: " + err.name);
}

try {
  console.log(`Template: ${id}`);
} catch (err) {
  console.log("Template literal: " + err.name);
}

console.log("toString(): " + id.toString());
console.log("String(): " + String(id));
Try It Yourself

How It Works

  1. The + operator refuses. To join a symbol with text, JavaScript would have to turn the symbol into a string by itself. It is not allowed, so a TypeError is thrown before anything is printed.
  2. Template literals refuse too. ${id} needs the same automatic conversion and throws a TypeError.
  3. Ask explicitly. id.toString() and String(id) both turn the symbol into text on purpose, so they work and print Symbol(userId).

Example 3 — List the Symbol Keys of an Object

Give an object two symbol keys, and show them as text. Normal tools such as Object.keys() do not list them.

JavaScript
const ID = Symbol("id");
const SECRET = Symbol("secret");

const user = { name: "Ana" };
user[ID] = 101;
user[SECRET] = "xyz";

const names = Object.getOwnPropertySymbols(user).map((key) => key.toString());

console.log("Symbol keys: " + names.join(", "));
console.log("Object.keys: " + Object.keys(user).join(", "));
console.log("Type check: " + Object.prototype.toString.call(ID));
Try It Yourself

How It Works

  1. Two hidden keys. ID and SECRET are used as property names, next to the normal property name.
  2. Find and print them. Object.getOwnPropertySymbols(user) returns the symbol keys in the order they were added. map() calls toString() on each one so they can be joined into one line.
  3. Normal tools skip them. Object.keys() shows only name. The last line shows that Object.prototype.toString reports the type [object Symbol].

Browser & Runtime Support

Symbol.prototype.toString() is part of ES2015 (ES6). Every current browser and Node.js has it.

✓ ES2015 · Widely supported

symbol.toString()

Supported in Chrome 38+, Edge 12+, Firefox 36+, Safari 9+, Opera 25+ and Node.js 0.12+. Internet Explorer never got it.

ES2015 Standard since
Google Chrome 38+ · Desktop & Mobile
Full support
Microsoft Edge 12+ · Chromium and legacy
Full support
Mozilla Firefox 36+ · Desktop & Mobile
Full support
Apple Safari 9+ · macOS & iOS
Full support
Opera 25+ · Chromium based
Full support
Samsung Internet Recent versions · Android
Supported
Android WebView 38+ · Chromium based
Supported
Node.js 0.12+ · Server runtime
Supported
Deno Supported · JavaScript runtime
Supported
Bun Supported · JavaScript runtime
Supported
Internet Explorer No native support
Not supported
symbol.toString() Excellent

Bottom line: Safe to use in every current browser and in Node.js. The only thing to plan for is Internet Explorer, which has no Symbol at all.

Frequently Asked Questions

Use symbol.toString() or String(symbol). Both return text like "Symbol(id)". If you only want the label, use symbol.description, which returns "id".
JavaScript does not convert symbols to text automatically. This stops you from turning a symbol into an ordinary string key by accident. Convert on purpose with toString(), String() or description.
toString() returns the full text "Symbol(id)". The description property returns only the label "id", and it is undefined when the symbol has no description. Use toString() for logs and description when you need the bare text.
No. Two different symbols with the same description give the same text, so Symbol("a").toString() === Symbol("a").toString() is true. The text is only for display. Compare the symbols themselves with ===.
Yes. console.log(symbol) prints the symbol as Symbol(id), because it handles symbols itself. The error only appears when your own code joins a symbol to text with + or a template literal.

Next: valueOf()

Learn how to get the primitive symbol out of a wrapper object, and why a symbol object is not equal to the symbol itself.

valueOf() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful