JavaScript toString() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Object

Definition

obj.toString() returns a string version of the object. For a plain object the default is "[object Object]".

You can override toString on your object or class for friendlier text. Object.prototype.toString.call(value) is also a classic way to read internal type tags like "[object Array]".

Syntax

Call obj.toString() like this. Start with this line.

JavaScript
obj.toString()
CallWhat it does
obj.toString()Returns a string; default plain object result is "[object Object]".
Object.prototype.toString.call([])Returns "[object Array]" — useful type tagging.
String(obj)Also ends up calling toString (or valueOf) during conversion.

No required parameters on Object.prototype.toString. Many other types override this method.

Library declarations
JavaScript
obj.toString()
JavaScript
object.toString(): string

Parameters

ParameterDescription
(none)Object.prototype.toString takes no parameters.

Return Value

Return ValueDescription
stringA string describing the object. Default for plain objects: "[object Object]".

JavaScript Examples

Default Plain Object String

See the built-in result and how string joining uses it.

JavaScript
var user = { name: "Ada" };

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

How It Works

  1. Default tag. Plain objects stringify to "[object Object]".
  2. Plus triggers it. Joining with a string calls string conversion behind the scenes.
  3. String() too. String(user) gives the same default text.

Override toString for Clearer Text

Add your own toString method on the object.

JavaScript
var user = {
  name: "Ada",
  age: 36,
  toString: function () {
    return this.name + " (" + this.age + ")";
  }
};

console.log(user.toString());
console.log("Hello, " + user);
Try It Yourself

How It Works

  1. Custom method. Your toString returns a friendly label.
  2. Used automatically. String joining picks up the override.
  3. Great for logs. Overriding helps debugging and simple displays.

Read Type Tags with toString.call

Borrow Object.prototype.toString to see internal tags.

JavaScript
function tag(value) {
  return Object.prototype.toString.call(value);
}

console.log(tag({}));
console.log(tag([]));
console.log(tag(null));
console.log(tag(42));
Try It Yourself

How It Works

  1. Object tag. A plain object reports [object Object].
  2. Array tag. Arrays report [object Array].
  3. Other tags. Even null and numbers have distinct tags this way.

Browser & Runtime Support

toString() has been part of JavaScript since ES1 and is Baseline in every environment.

✓ ES1 · Baseline

obj.toString()

Universal support. One of the most common methods in everyday JavaScript.

100% Browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Object.prototype.toString Excellent

Bottom line: Available everywhere. Override it for readable objects; use Object.prototype.toString.call for type tags.

Frequently Asked Questions

That is the default Object.prototype.toString result for plain objects. Override toString if you want custom text.
Add a toString method on the object or on its prototype that returns the string you want.
During string conversion: joining with +, template contexts that stringify, String(obj), and some logging paths.
It reveals internal type tags such as [object Array] or [object Date], which is handy for type checks.
No. JSON.stringify builds JSON text from data. toString is a general string conversion hook.

Next: valueOf()

Get the primitive value of an object.

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.

8 people found this page helpful