The Symbol.toStringTag well-known symbol is a string valued property that is used in the creation of the default string description of an object. It is accessed internally by the Object.prototype.toString() method.

Property attributes of Symbol.toStringTag
Writable no
Enumerable no
Configurable no


Default tags'foo');     // "[object String]"[1, 2]);    // "[object Array]";         // "[object Number]";      // "[object Boolean]"; // "[object Undefined]";      // "[object Null]"
// ... and more

Built-in toStringTag symbols Map());       // "[object Map]"* () {}); // "[object GeneratorFunction]"; // "[object Promise]"
// ... and more

Custom classes default to object tag

When creating your own class, JavaScript defaults to the "Object" tag:

class ValidatorClass {} ValidatorClass()); // "[object Object]"

Custom tag with toStringTag

Now, with the help of toStringTag, you are able to set your own custom tag:

class ValidatorClass {
  get [Symbol.toStringTag]() {
    return 'Validator';
} ValidatorClass()); // "[object Validator]"

toStringTag available on all DOM prototype objects

Due to a WebIDL spec change in mid-2020, browsers are adding a Symbol.toStringTag property to all DOM prototype objects. For example, to acccess the Symbol.toStringTag property on HTMLButtonElement:

let test = document.createElement('button');
test.toString(); // Returns [object HTMLButtonElement]
test[Symbol.toStringTag];  // Returns HTMLButtonElement


ECMAScript (ECMA-262)
The definition of 'Symbol.toStringTag' in that specification.

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
toStringTagChrome Full support 49Edge Full support 15Firefox Full support 51IE No support NoOpera Full support 36Safari Full support 10WebView Android Full support 49Chrome Android Full support 49Firefox Android Full support 51Opera Android Full support 36Safari iOS Full support 10Samsung Internet Android Full support 5.0nodejs Full support 6.0.0
Full support 6.0.0
Full support 4.0.0
Disabled From version 4.0.0: this feature is behind the --harmony runtime flag.
toStringTag available on all DOM prototype objectsChrome Full support 50Edge Full support 79Firefox Full support 78IE No support NoOpera Full support 37Safari Full support 14WebView Android Full support 50Chrome Android Full support 50Firefox Android No support NoOpera Android Full support 37Safari iOS Full support 14Samsung Internet Android Full support 5.0nodejs No support No


Full support  
Full support
No support  
No support
User must explicitly enable this feature.
User must explicitly enable this feature.

See also