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


Many JavaScript types have tags by default:'foo');     // "[object String]"[1, 2]);    // "[object Array]";         // "[object Number]";      // "[object Boolean]"; // "[object Undefined]";      // "[object Null]"
// ... and more

Others have a built-in toStringTag symbol defined: Map());       // "[object Map]"* () {}); // "[object GeneratorFunction]"; // "[object Promise]"
// ... and more

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

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

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]"


Specification Status Comment
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'Symbol.toStringTag' in that specification.
Standard Initial definition.
ECMAScript Latest Draft (ECMA-262)
The definition of 'Symbol.toStringTag' in that specification.

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support491551 No Yes Yes
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support Yes Yes Yes51 Yes Yes Yes

1. From version 4.0.0: this feature is behind the --harmony runtime flag.

See also

Document Tags and Contributors

Contributors to this page: wbamberg, fscholz, jameshkramer, nmve, kdex, ZeikJT
Last updated by: wbamberg,