Favorites

JavaScript Error.prototype.message Property

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Error.prototype.message
JavaScript Error Instance propertyThis property is supported by all modern browsers.
Updated 28th November 2026

The message property of an Error holds the human-readable description of what went wrong.

Description

The message property contains a human-readable description of the error, set by the first argument to the constructor. Together with name, it's what you usually log or show. Built-in error messages differ between browsers, so don't write code that depends on their exact wording.

You can include useful context in your own messages, such as the value that was invalid: new RangeError(`Quantity must be 1-10, got ${qty}`). Avoid putting sensitive data, such as passwords or tokens, in messages, since they often end up in logs.

When showing errors to users, a friendly message written for them is usually better than the technical message, which you can log for developers instead. Converting an error to a string gives "Name: message".

Syntax

error.message

Value

A string describing the error.

Example

try {
  null.x;
} catch (err) {
  console.log(err.message);
}
console.log(new Error('Disk full').message);

Browser Support

The following information will show you the current browser support for the Error.prototype.message property. Hover over a browser icon to see the version that first introduced support for this property.

This property is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee