103

It's possible to browse the commands previously run in the console by pressing the up and down arrow keys. I want to clear this history. How can I do this?

Aryan Beezadhur
  • 4,503
  • 4
  • 21
  • 42
Herry Kusmadi
  • 1,281
  • 3
  • 12
  • 13
  • 1
    If your console gets too big, chrome on Windows gives this error: `Error saving setting with name: consoleHistory, value length: 6367742. Error: Failed to set the 'consoleHistory' property on 'Storage': Setting the value of 'consoleHistory' exceeded the quota.` Clearing the console history fixes this. – Josiah Sep 28 '16 at 10:46
  • 1
    Possible duplicate of [how do I clear google chrome console suggessions](http://stackoverflow.com/questions/18885409/how-do-i-clear-google-chrome-console-suggessions) – user Dec 01 '16 at 08:51
  • Related posts - [clear javascript console in Google Chrome](https://stackoverflow.com/q/3011600/465053) & [How to clear Chrome console by shortcut keys?](https://stackoverflow.com/q/5483451/465053) – RBT Jun 21 '19 at 02:17

10 Answers10

241

You can now just right click on the console area and select "Clear console history".

enter image description here

Jeff Lamb
  • 5,755
  • 4
  • 37
  • 54
  • 43
    While the other answer is a super cool "chromeception" moment, this should be the top voted/correct answer now. – KhalilRavanna Jul 06 '16 at 21:50
  • This was the only working solution for me. The "chromeception" variant crashed when trying to examine the Localstorage resources on the second Devtools window. Likely because there was too much data in my history – Mischa Rodermond Jul 15 '16 at 08:33
  • 4
    I even did't try the context menu and started to google %) – starikovs Aug 10 '16 at 16:17
  • 5
    This should be top answer, as the accepted answer is no longer correct. – neilsimp1 Nov 29 '16 at 18:32
  • 2
    I didn’t find this option because it depends on where in the console you click. If you click within the line of text where you type, you get a different menu which doesn’t have this option. I think your answer should mention that. – Timwi Apr 19 '19 at 13:34
  • Didn't worked for me. How do i clear all the assignments? – iheathers Dec 27 '20 at 05:17
132

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 , 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.

Rob W
  • 341,306
  • 83
  • 791
  • 678
  • I did not find "consoleHistory" on Resources tab. there is only Frames, Web SQL, IndexedDB, Local Storage, Session Storage, Cookies, Application Cache – Herry Kusmadi Jan 15 '14 at 22:25
  • @HerryKusmadi It's an item under "Local storage", see picture. – Rob W Jan 15 '14 at 22:25
  • 3
    still not find in local storage, because no chrome-DevTools in it. see this http://i.imgur.com/Cs43DRL.png – Herry Kusmadi Jan 15 '14 at 22:35
  • 16
    @HerryKusmadi Step 1 and 2 are important, don't skip them! – Rob W Jan 15 '14 at 22:37
  • 7
    This is a 'debug the debugger'. I think it could be helpful to explain that there is no "official" feature to clear the console history, rather this very, very clever and useful hack. – Zero Distraction Dec 29 '14 at 05:44
  • 1
    Oh So nice! What a hack! – the Explorer Jul 24 '15 at 18:11
  • The second console window will close automatically for me after a few seconds. It also does not give me the option to right-click. – docta_faustus Dec 18 '15 at 15:19
  • 1
    @docta_faustus Works fine for me in Chrome 47.0.2526.80. The first step is slightly different (these icons are now hidden behind a dotted line at the upper-right corner), but the rest of the answer is still valid. – Rob W Dec 18 '15 at 15:22
  • @Martin It still works for me in Chrome 49.0.2623.75. Did you close and re-open the devtools after deleting the entry? – Rob W Mar 18 '16 at 15:41
  • There is no entry at all. I have only `localhost` in my **Local Storage** dropdown. Nothing with `chrome-devtools://` – xyhhx Mar 18 '16 at 15:42
  • 2
    @Martin In that case, please read every step in my answer (and all comments below it, since you are repeating exactly the same mistake). – Rob W Mar 18 '16 at 15:43
  • Just tried on Chrome `50.0.2661.49 beta-m` and still works! – nyuen Mar 29 '16 at 23:23
  • 1
    Wow! This is like "Inception" – dream within a dream... And yes, I tried other "levels of dreams" and they looked similar to the 2nd level of debugger. – Ricardo Sep 22 '16 at 17:22
  • 13
    On Crome `53` (an maybe earlier versions too), the `Resources` tab is `Application` – Ricardo Sep 22 '16 at 17:25
  • Pls notice that opening debugger's debugger may cause some side-effects on the debugger. I had to restart Chrome to fix them. – Ricardo Sep 22 '16 at 22:14
  • 1
    Even I tried to be smart and skipped the steps, then I realized how fool I was :/ . – ashishyadaveee11 Apr 03 '17 at 07:10
  • 2
    Super cool solution. While rightclick + clear console history clears everything in an easier way, I was able to use this to replace a password I used in the history string. This way I didn't lose my history :) – tietze111 Jun 01 '18 at 06:43
  • 2
    In newer versions of Chrome (as of this writing, Chrome 69) there's no need to undock the console. Instead, just look under the Application tab and select Local Storage in the left sidebar. But the other answers are more up-to-date anyway. – Galen Long Oct 03 '18 at 19:46
  • 2
    Why it is so complicated? Chrome should provide a simple button to clear history. – aagjalpankaj Jun 19 '19 at 16:55
  • 1
    Actually as of chrome 93 and possibly sooner all you have to do is right click on the console display itself. – wheredidthatnamecomefrom Sep 13 '21 at 18:50
72

I found a quick way to do this with cool keyboard shortcut:

Inside chrome console

  1. Press Ctrl + Shift + P
  2. You will see this awesome command palette opened: chrome devtools command palette
  3. type clear and you will find it :) chrome devtools: clear console history

That's it!

jurl
  • 2,504
  • 1
  • 17
  • 20
11

If you don't want to have this console history (like myself), simply disable it from the devtool's configuration options (see on the image) below ...

enter image description here

asiby
  • 3,229
  • 29
  • 32
  • 1
    Thanks! Exactly what I was looking for. I like the history being there when I press up & down, but one local app's history being autocompleted when working on another app is... not useful. – chadoh Jun 17 '16 at 12:45
10

This is very simple, just right click the console window and select Clear console history, then refresh the page.

Please note, refreshing/reloading that tab is required.


enter image description here

Kostas Minaidis
  • 4,681
  • 3
  • 17
  • 25
Diwakar
  • 878
  • 1
  • 9
  • 14
4

I ended up here looking for how to do the same thing in Firefox.

In case anyone else does the same, there is a clearHistory command in the Firefox console which will do just that.

https://developer.mozilla.org/en-US/docs/Tools/Web_Console/The_command_line_interpreter#Helper_commands

vitch
  • 3,215
  • 3
  • 25
  • 26
3

Simply enter clear() in the chrome console to remove all previous text there.

mjkaufer
  • 4,047
  • 5
  • 27
  • 55
1

You can do that now easily with

  1. cmd + shift + p
  2. Type "clear"
  3. Choose Clear console history

enter image description here

Juan Rangel
  • 1,763
  • 1
  • 18
  • 34
0

It can also be fixed by going to the developer tool settings and resetting to defaults.. (this will not reset 'Chrome', only developer tools options)

  • Open Chrome devtools
  • Go to settings (or press Windows ->F1 / OS X -> FN + F1)
  • Reset to the defaults

This way you will lose your developer settings, but for me the only thing that mattered was turning cache off again..

DutchKevv
  • 1,659
  • 2
  • 22
  • 39
-1

These shortcuts Clear Console.

⌘ K or Ctrl L

Clay Morton
  • 333
  • 2
  • 15