Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

clear javascript console in Google Chrome

People also ask

How do you clear the console code?

Use Ctrl + K to clear the terminal.

What does console Clear () do?

Clears the console buffer and corresponding console window of display information.

How do I refresh the chrome console?

Whenever you are working chrome, try this: Press F12 and open the developer tools. On the refresh button, on the top left of the browser window, do a right click.


Update: console.clear() is available in all browsers

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


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

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.


There's always the good ol' trick:

console.log("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");

or a shorter variation of the above:

console.log('\n'.repeat('25'));

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.


This seems to work just fine:

console.clear();

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.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!