clear javascript console in Google Chrome

clear javascript console in Google Chrome

I was wondering if I could clear up the console with some command..
console.log(), can print… is there a command to clear up console?..
I’ve tried to console.log(console); and got this functions below…
assert: function assert() { [native code] }
constructor: function Console() { [native code] }
count: function count() { [native code] }
debug: function debug() { [native code] }
dir: function dir() { [native code] }
dirxml: function dirxml() { [native code] }
error: function error() { [native code] }
group: function group() { [native code] }
groupEnd: function groupEnd() { [native code] }
info: function info() { [native code] }
log: function log() { [native code] }
markTimeline: function markTimeline() { [native code] }
profile: function profile() { [native code] }
profileEnd: function profileEnd() { [native code] }
time: function time() { [native code] }
timeEnd: function timeEnd() { [native code] }
trace: function trace() { [native code] }
warn: function warn() { [native code] }
__proto__: Object

[ I guess there’s no way to clear up the console… but I wanted someone to say it to me… ]


Solution 1:

Update: As of November 6, 2012, console.clear() is now available in Chrome Canary.

If you type clear() into the console it clears it.

Related:  require is not defined? Node.js

I don’t think there is a way to programmatically do it, as it could be misused. (console is cleared by some web page, end user can’t access error information)

one possible workaround:

in the console type window.clear = clear, then you’ll be able to use clear in any script on your page.

Solution 2:

There’s always the good ol’ trick:


Not the most elegant solution, I know 🙂 … but works.

For me, I usually just print a long “—–” separator line to help make the logs easier to read.

Solution 3:

This seems to work just fine:


Solution 4:

If you use console.clear(), that seems to work in chrome. Note, it will output a “Console was cleared” message.

I tested this by racking up a ton of Javascript errors.

Note, I got an error right after clearing the console, so it doesn’t disable the console, only clears it. Also, I have only tried this in chrome, so I dont know how cross-browser it is.

EDIT: I tested this in Chrome, IE, Firefox, and Opera. It works in Chrome, MSIE and Opera’s default consoles, but not in Firefox’s, however, it does work in Firebug.

Related:  Save current Google Map as image

Solution 5:

Chrome Console Clear button

If you want to just clear the console when debugging, you can simply click the “ban-circle” button to clear console.log.

Alternatively just press “Ctrl+L” to clear the console using your keyboard.

Solution 6:





You can create your own variable, which works in both:

if (typeof console._commandLineAPI !== 'undefined') {
    console.API = console._commandLineAPI;
} else if (typeof console._inspectorCommandLineAPI !== 'undefined') {
    console.API = console._inspectorCommandLineAPI;
} else if (typeof console.clear !== 'undefined') {
    console.API = console;

After that, you can simply use console.API.clear().