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
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Console | Chrome Full support 1 | Edge Full support 12 | Firefox Full support 2 | IE
Full support
8
| Opera Full support 10.5 | Safari Full support 3 | WebView Android Full support 1 | Chrome Android Full support 18 | Firefox Android Full support 4 | Opera Android Full support 11 | Safari iOS Full support 1 | Samsung Internet Android Full support 1.0 |
assert | Chrome Full support 1 | Edge Full support 12 | Firefox Full support 28 | IE Full support 8 | Opera Full support 11 | Safari Full support 4 | WebView Android Full support 1 | Chrome Android Full support 18 | Firefox Android Full support 28 | Opera Android Full support 11 | Safari iOS Full support 3.2 | Samsung Internet Android Full support 1.0 |
clear | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 48 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 48 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support Yes |
count | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 30 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 30 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support Yes |
countReset | Chrome Full support Yes | Edge Full support ≤79 | Firefox Full support 62 | IE No support No | Opera Full support Yes | Safari ? | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 62 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support Yes |
debug | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 4 | IE Full support Yes | Opera ? | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support Yes |
dir | Chrome Full support 1 | Edge Full support 12 | Firefox Full support 8 | IE Full support 9 | Opera Full support 11 | Safari Full support 4 | WebView Android Full support 1 | Chrome Android Full support 18 | Firefox Android Full support 8 | Opera Android Full support 11 | Safari iOS Full support 3.2 | Samsung Internet Android Full support 1.0 |
dirxml | Chrome Full support Yes | Edge Full support 12 | Firefox Full support Yes | IE Full support Yes | Opera Full support Yes | Safari ? | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android No support No | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support Yes |
error | Chrome Full support 1 | Edge Full support 12 | Firefox Full support 4 | IE Full support 8 | Opera Full support 10.5 | Safari Full support 3 | WebView Android Full support 1 | Chrome Android Full support 18 | Firefox Android Full support 4 | Opera Android Full support 11 | Safari iOS Full support 1 | Samsung Internet Android Full support 1.0 |
exception (an alias for error ) | Chrome No support No | Edge No support 13 — 79 | Firefox Full support 28 | IE No support No | Opera No support No | Safari No support No | WebView Android No support No | Chrome Android No support No | Firefox Android Full support 28 | Opera Android ? | Safari iOS No support No | Samsung Internet Android No support No |
group | Chrome Full support 1 | Edge Full support 12 | Firefox Full support 4 | IE Full support 11 | Opera Full support Yes | Safari Full support 4 | WebView Android Full support 37 | Chrome Android Full support 18 | Firefox Android Full support 4 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support 1.0 |
groupCollapsed | Chrome Full support 6 | Edge Full support 12 | Firefox Full support 52 | IE Full support 11 | Opera ? | Safari Full support 5.1 | WebView Android Full support 37 | Chrome Android Full support 18 | Firefox Android Full support 52 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support 1.0 |
groupEnd | Chrome Full support 1 | Edge Full support 12 | Firefox Full support 9 | IE Full support 11 | Opera Full support Yes | Safari Full support 4 | WebView Android Full support 37 | Chrome Android Full support 18 | Firefox Android Full support 9 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support 1.0 |
info | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 4 | IE Full support 8 | Opera Full support Yes | Safari
Full support
Yes
| WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support Yes |
log | Chrome Full support 1 | Edge Full support 12 | Firefox Full support 4 | IE Full support 8 | Opera Full support 10.5 | Safari Full support 3 | WebView Android Full support 1 | Chrome Android Full support 18 | Firefox Android Full support 4 | Opera Android Full support 11 | Safari iOS Full support 1 | Samsung Internet Android Full support 1.0 |
profile | Chrome Full support 53 | Edge Full support 12 | Firefox Full support Yes | IE Full support Yes | Opera ? | Safari ? | WebView Android Full support 53 | Chrome Android Full support 53 | Firefox Android Full support 10 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support 6.0 |
profileEnd | Chrome Full support Yes | Edge Full support 12 | Firefox Full support Yes | IE Full support Yes | Opera ? | Safari ? | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 10 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support Yes |
table | Chrome Full support 27 | Edge Full support 13 | Firefox Full support 34 | IE No support No | Opera Full support 11 | Safari Full support 6.1 | WebView Android Full support ≤37 | Chrome Android Full support 27 | Firefox Android Full support 34 | Opera Android Full support 11 | Safari iOS Full support 7 | Samsung Internet Android Full support 1.5 |
time | Chrome Full support 1 | Edge Full support 12 | Firefox Full support 10 | IE Full support 11 | Opera Full support 11 | Safari Full support 4 | WebView Android Full support 1 | Chrome Android Full support 18 | Firefox Android Full support 10 | Opera Android Full support 11 | Safari iOS Full support 3.2 | Samsung Internet Android Full support 1.0 |
timeEnd | Chrome Full support 1 | Edge Full support 12 | Firefox Full support 10 | IE Full support 11 | Opera Full support Yes | Safari Full support 4 | WebView Android Full support 1 | Chrome Android Full support 18 | Firefox Android Full support 10 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support 1.0 |
timeLog | Chrome Full support 72 | Edge Full support 79 | Firefox Full support 62 | IE No support No | Opera Full support 60 | Safari
No support
No
| WebView Android Full support 72 | Chrome Android Full support 72 | Firefox Android Full support 62 | Opera Android ? | Safari iOS No support No | Samsung Internet Android Full support 11.0 |
timestamp | Chrome Full support Yes | Edge Full support 12 | Firefox Full support Yes | IE Full support 11 | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 10 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support Yes |
trace | Chrome Full support 1 | Edge Full support 12 | Firefox Full support 10 | IE Full support 11 | Opera Full support 11 | Safari Full support 4 | WebView Android Full support 1 | Chrome Android Full support 18 | Firefox Android Full support 10 | Opera Android Full support 11 | Safari iOS Full support 3.2 | Samsung Internet Android Full support 1.0 |
warn | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 4 | IE Full support 8 | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support Yes |
Available in workers | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 38 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 38 | Opera 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