Console API

You’re reading the English version of this content since no translation exists yet for this locale. Help us translate this article!

The Console API provides functionality to allow developers to perform debugging tasks, such as logging messages or the values of variables at set points in your code, or timing how long an operation takes to complete.

Concepts and usage

The Console API started as a largely proprietary API, with different browsers implementing it, albeit it in inconsistent ways. The Console API spec was created to define consistent behavior, and all modern browsers eventually settled on implementing this behavior — although some implementations still have their own additional proprietary functions. Find out about these at:

Usage is very simple — the console object — available via window.console, or WorkerGlobalScope.console in workers; accessible using just console — contains many methods that you can call to perform rudimentary debugging tasks, generally focused around logging various values to the browser's Web Console.

By far the most commonly-used method is console.log, which is used to log the current value contained inside a specific variable.

Interfaces

console
Provides rudimentary debugging functionality, including logging, stack traces, timers, and counters.

Examples

let myString = 'Hello world';

// Output "Hello world" to the console
console.log(myString)

See the Console reference page for more examples.

Specifications

Specification Status Comment
Console API Living Standard Initial definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
ConsoleChrome Full support 4Edge Full support YesFirefox Full support 2IE Partial support 8
Notes
Partial support 8
Notes
Notes Only functions when developer tools are opened. Otherwise, the 'console' object is undefined.
Opera Full support 10.1Safari Full support 3.1WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 4Opera Android ? Safari iOS Full support 3.2Samsung Internet Android Full support Yes
assertChrome Full support YesEdge Full support 12Firefox Full support 28IE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 28Opera Android ? Safari iOS ? Samsung Internet Android ?
clearChrome Full support YesEdge Full support 12Firefox Full support 48IE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 48Opera Android ? Safari iOS ? Samsung Internet Android ?
countChrome Full support YesEdge Full support 12Firefox Full support 30IE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 30Opera Android ? Safari iOS ? Samsung Internet Android ?
countResetChrome Full support YesEdge ? Firefox Full support 62IE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 62Opera Android ? Safari iOS ? Samsung Internet Android Full support Yes
debugChrome Full support YesEdge Full support 12Firefox Full support 4IE Full support YesOpera ? Safari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 4Opera Android ? Safari iOS ? Samsung Internet Android ?
dir
ExperimentalNon-standard
Chrome Full support YesEdge Full support 12Firefox Full support 8IE Full support 9Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 8Opera Android ? Safari iOS ? Samsung Internet Android ?
dirxml
ExperimentalNon-standard
Chrome Full support YesEdge Full support 12Firefox Full support YesIE Full support YesOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesFirefox Android No support NoOpera Android ? Safari iOS ? Samsung Internet Android ?
errorChrome Full support YesEdge Full support 12Firefox Full support 4IE Full support 8Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 4Opera Android ? Safari iOS ? Samsung Internet Android ?
exception (an alias for error)
DeprecatedNon-standard
Chrome No support NoEdge Full support 13Firefox Full support 28IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoFirefox Android Full support 28Opera Android ? Safari iOS No support NoSamsung Internet Android No support No
groupChrome Full support 4Edge Full support 12Firefox Full support 4IE Full support 11Opera Full support YesSafari Full support 4WebView Android Full support 37Chrome Android Full support 18Firefox Android Full support 4Opera Android ? Safari iOS ? Samsung Internet Android ?
groupCollapsedChrome Full support 6Edge Full support 12Firefox Full support 52IE Full support 11Opera ? Safari Full support 5.1WebView Android Full support 37Chrome Android Full support 18Firefox Android Full support 52Opera Android ? Safari iOS ? Samsung Internet Android ?
groupEndChrome Full support 4Edge Full support 12Firefox Full support 9IE Full support 11Opera Full support YesSafari Full support 4WebView Android Full support 37Chrome Android Full support 18Firefox Android Full support 9Opera Android ? Safari iOS ? Samsung Internet Android ?
infoChrome Full support YesEdge Full support 12Firefox Full support 4IE Full support 8Opera Full support YesSafari Full support Yes
Notes
Full support Yes
Notes
Notes No information icon
WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 4Opera Android ? Safari iOS ? Samsung Internet Android ?
logChrome Full support YesEdge Full support 12Firefox Full support 4IE Full support 8Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 4Opera Android ? Safari iOS ? Samsung Internet Android ?
profile
ExperimentalNon-standard
Chrome Full support 53Edge Full support 12Firefox Full support YesIE Full support YesOpera ? Safari ? WebView Android Full support 53Chrome Android Full support 53Firefox Android Full support 10Opera Android ? Safari iOS ? Samsung Internet Android ?
profileEnd
ExperimentalNon-standard
Chrome Full support YesEdge Full support 12Firefox Full support YesIE Full support YesOpera ? Safari ? WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 10Opera Android ? Safari iOS ? Samsung Internet Android ?
tableChrome Full support YesEdge Full support 13Firefox Full support 34IE No support NoOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 34Opera Android ? Safari iOS ? Samsung Internet Android ?
timeChrome Full support 4Edge Full support 12Firefox Full support 10IE Full support 11Opera Full support YesSafari Full support 4WebView Android Full support 37Chrome Android Full support 18Firefox Android Full support 10Opera Android ? Safari iOS ? Samsung Internet Android ?
timeEndChrome Full support 4Edge Full support 12Firefox Full support 10IE Full support 11Opera Full support YesSafari Full support 4WebView Android Full support 37Chrome Android Full support 18Firefox Android Full support 10Opera Android ? Safari iOS ? Samsung Internet Android ?
timeLogChrome Full support 72Edge No support NoFirefox Full support 62IE No support NoOpera Full support 60Safari No support No
Notes
No support No
Notes
Notes See bug 186833.
WebView Android Full support 72Chrome Android Full support 72Firefox Android Full support 62Opera Android ? Safari iOS No support NoSamsung Internet Android No support No
timestamp
ExperimentalNon-standard
Chrome Full support YesEdge Full support 12Firefox Full support YesIE Full support 11Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 10Opera Android ? Safari iOS ? Samsung Internet Android ?
traceChrome Full support YesEdge Full support 12Firefox Full support 10IE Full support 11Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 10Opera Android ? Safari iOS ? Samsung Internet Android ?
warnChrome Full support YesEdge Full support 12Firefox Full support 4IE Full support 8Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 4Opera Android ? Safari iOS ? Samsung Internet Android ?
Available in workersChrome Full support YesEdge Full support YesFirefox Full support 38IE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 38Opera Android ? Safari iOS ? Samsung Internet Android ?

Legend

Full support  
Full support
Partial support  
Partial support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
Non-standard. Expect poor cross-browser support.
Non-standard. Expect poor cross-browser support.
Deprecated. Not for use in new websites.
Deprecated. Not for use in new websites.
See implementation notes.
See implementation notes.

See also

  • Tools
  • Web Console — how the Web Console in Firefox handles console API calls
  • Remote debugging — how to see console output when the debugging target is a mobile device