Clear JavaScript Console in Google Chrome

clear javascript console in Google Chrome

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.

Chrome console clear assignment and variables

Easiest way to clear data from the console is to refresh the page.

What you are affecting when declaring any variables or functions within the developer console is the global execution context, which for web browsers is window.

When you clear() the console you are telling Chrome to remove all visible history of these operations, not clear the objects that you have attached to window.

how do I clear google chrome console suggessions

[EDIT] As of Chrome 50, you can use "Clear console history" from the console context menu.

Clear console history - Chrome DevTools


The situation seems to be a bit unlikely to happen (confident information in the devtools console?), but I've found the problem of clearing command history interesting. Especially, when it turned out that nothing from the 'Settings'->'Clear browsing data...' clears it. Closing the tab or restarting the browser doesn't help either.

First, I've opened DevTools (A) in a separate window:

DevTools - detaching window

Then, knowing that DevTools are in fact a webapp, I've opened another DevTools window (B) inside already opened one (A) using keyboard shortcut. Next, I've navigated to the "Resoures" tab, and in the "Local storage" section found a consoleHistory entry.

DevTools - clearing command history

After removing it (right-click and "Delete") and closing both DevTools windows (A and B) I found my console history empty.

How to clear console history

If you want to clear the list of last typed commands, follow these steps:

(Step 1 and 2 are important, don't skip them!)

  1. Undock the console (click on the icon in the bottom-left corner, undock icon).

    (if you don't see the undock icon, but Sample Image, then hold the mouse pressed for a few seconds to get the desired icon)
  2. Press Ctrl + Shift + J to open the console for this console. (On OSX use Cmd + Option + i)
  3. Go to the Resources tab, "Local Storage", chrome-devtools://devtools.
  4. Right-click on the item with key "consoleHistory", and choose "Delete".
    chrome-devtools://devtools -> consoleHistory -> Delete

  5. Done! You may close the new console, and then dock the previous one if wanted. The console history will be gone when you reload the console.

If you just want to clear the console log (not the commands), just press Ctrl + L.

You could also use Incognito mode if you don't want to keep the list of commands you're going to type.

How to clear Chrome console by shortcut keys?

You can use Ctrl + L to clear the chrome-dev-console on Windows/Linux and Cmd + K on Mac.



Related Topics



Leave a reply



Submit