CKTIS / JavaScript
Symbol.toStringTag — a custom object tag
Symbol.toStringTag is a well-known symbol used as the property key that supplies the tag in Object.prototype.toString() output. It changes an object's description, not its actual type.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
const value = { [Symbol.toStringTag]: "Widget" };
Object.prototype.toString.call(value);Symbol.toStringTag is a well-known symbol, not a method. An object property with this key can supply the string used by Object.prototype.toString.call(value) to produce a result such as [object Widget]. The symbol key is not the same as the string key "Symbol.toStringTag".
The method also reads this property through the prototype chain. If its value is not a string, it uses the default tag, such as Object for an ordinary object; it does not convert the value to a string. A getter may run, and any exception it throws propagates.
The tag is descriptive, not a reliable type check: it can be spoofed. It does not change typeof, the prototype, or the object's internal capabilities. It also does not replace a custom toString() method or control primitive conversion in general — that is the role of Symbol.toPrimitive.
Examples
const item = { [Symbol.toStringTag]: "Widget" };
console.log(Object.prototype.toString.call(item));
item[Symbol.toStringTag] = 42;
console.log(Object.prototype.toString.call(item));
console.log(typeof item);Result
[object Widget] [object Object] object
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.