Console API

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 1Edge Full support 12Firefox Full support 4IE Full support 8
Notes
Full support 8
Notes
Notes In Internet Explorer 8 and 9, the console object is undefined when the developer tools are not open. This behavior was fixed in Internet Explorer 10.
Opera Full support 10.5Safari Full support 3WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 11Safari iOS Full support 1Samsung Internet Android Full support 1.0
assertChrome Full support 1Edge Full support 12Firefox Full support 28IE Full support 8Opera Full support 11Safari Full support 4WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 28Opera Android Full support 11Safari iOS Full support 3.2Samsung Internet Android Full support 1.0
clearChrome Full support 25Edge Full support 12Firefox Full support 39IE Full support 8Opera Full support 12Safari Full support 6.1WebView Android Full support ≤37Chrome Android Full support 25Firefox Android Full support 39Opera Android Full support 12Safari iOS Full support 7Samsung Internet Android Full support 1.5
countChrome Full support 1Edge Full support 12Firefox Full support 30IE Full support 11Opera Full support 11Safari Full support 4WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 30Opera Android Full support 11Safari iOS Full support 3.2Samsung Internet Android Full support 1.0
countResetChrome Full support 68Edge Full support 79Firefox Full support 62IE No support NoOpera Full support 55Safari Full support 13WebView Android Full support 68Chrome Android Full support 68Firefox Android Full support 62Opera Android Full support 48Safari iOS Full support 13Samsung Internet Android Full support 10.0
debugChrome Full support 1Edge Full support 12Firefox Full support 4IE Full support 10Opera Full support 11Safari Full support 4WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 11Safari iOS Full support 3.2Samsung Internet Android Full support 1.0
dir
Experimental
Chrome Full support 1Edge Full support 12Firefox Full support 8IE Full support 9Opera Full support 11Safari Full support 4WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 8Opera Android Full support 11Safari iOS Full support 3.2Samsung Internet Android Full support 1.0
dirxml
Experimental
Chrome Full support 1Edge Full support 12Firefox Full support 39IE Full support 11Opera Full support 11Safari Full support 4WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 39Opera Android Full support 11Safari iOS Full support 3.2Samsung Internet Android Full support 1.0
errorChrome Full support 1Edge Full support 12Firefox Full support 4IE Full support 8Opera Full support 10.5Safari Full support 3WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 11Safari iOS Full support 1Samsung Internet Android Full support 1.0
exception (an alias for error)
DeprecatedNon-standard
Chrome No support NoEdge No support 13 — 79Firefox 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 1Edge Full support 12Firefox Full support 4IE Full support 11Opera Full support 11Safari Full support 4WebView Android Full support 37Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 11Safari iOS Full support 3.2Samsung Internet Android Full support 1.0
groupCollapsedChrome Full support 6Edge Full support 12Firefox Full support 9IE Full support 11Opera Full support 11Safari Full support 5.1WebView Android Full support 37Chrome Android Full support 18Firefox Android Full support 9Opera Android Full support 11Safari iOS Full support 5.1Samsung Internet Android Full support 1.0
groupEndChrome Full support 1Edge Full support 12Firefox Full support 9IE Full support 11Opera Full support 11Safari Full support 4WebView Android Full support 37Chrome Android Full support 18Firefox Android Full support 9Opera Android Full support 11Safari iOS Full support 3.2Samsung Internet Android Full support 1.0
infoChrome Full support 1Edge Full support 12Firefox Full support 4IE Full support 8Opera Full support 10.5Safari Full support 3WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 11Safari iOS Full support 1Samsung Internet Android Full support 1.0
logChrome Full support 1Edge Full support 12Firefox Full support 4IE Full support 8Opera Full support 10.5Safari Full support 3WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 11Safari iOS Full support 1Samsung Internet Android Full support 1.0
profile
ExperimentalNon-standard
Chrome Full support 4Edge Full support 12Firefox Full support 16IE Full support 9Opera Full support 11Safari Full support 4WebView Android Full support ≤37Chrome Android Full support 18Firefox Android Full support 16Opera Android Full support 11Safari iOS Full support 3.2Samsung Internet Android Full support 1.0
profileEnd
ExperimentalNon-standard
Chrome Full support 4Edge Full support 12Firefox Full support 16IE Full support 9Opera Full support 11Safari Full support 4WebView Android Full support ≤37Chrome Android Full support 18Firefox Android Full support 16Opera Android Full support 11Safari iOS Full support 3.2Samsung Internet Android Full support 1.0
tableChrome Full support 27Edge Full support 13Firefox Full support 34IE No support NoOpera Full support 11Safari Full support 6.1WebView Android Full support ≤37Chrome Android Full support 27Firefox Android Full support 34Opera Android Full support 11Safari iOS Full support 7Samsung Internet Android Full support 1.5
timeChrome Full support 1Edge Full support 12Firefox Full support 10IE Full support 11Opera Full support 11Safari Full support 4WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 10Opera Android Full support 11Safari iOS Full support 3.2Samsung Internet Android Full support 1.0
timeEndChrome Full support 1Edge Full support 12Firefox Full support 10IE Full support 11Opera Full support 11Safari Full support 4WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 10Opera Android Full support 11Safari iOS Full support 3.2Samsung Internet Android Full support 1.0
timeLogChrome Full support 71Edge Full support 79Firefox Full support 62IE No support NoOpera Full support 60Safari Full support 13WebView Android Full support 71Chrome Android Full support 71Firefox Android Full support 62Opera Android Full support 50Safari iOS Full support 13Samsung Internet Android Full support 10.0
timeStamp
ExperimentalNon-standard
Chrome Full support 14Edge Full support 12Firefox Full support 39IE Full support 11Opera Full support 15Safari Full support 6WebView Android Full support ≤37Chrome Android Full support 18Firefox Android Full support 39Opera Android Full support 14Safari iOS Full support 6Samsung Internet Android Full support 1.0
traceChrome Full support 1Edge Full support 12Firefox Full support 10IE Full support 11Opera Full support 11Safari Full support 4WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 10Opera Android Full support 11Safari iOS Full support 3.2Samsung Internet Android Full support 1.0
warnChrome Full support 1Edge Full support 12Firefox Full support 4IE Full support 8Opera Full support 10.5Safari Full support 3WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 11Safari iOS Full support 1Samsung Internet Android Full support 1.0
Available in workersChrome Full support YesEdge Full support 12Firefox 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 Full support Yes

Legend

Full support  
Full 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