How to Clear the JavaScript Console in Google Chrome

In this article we are going to learn how to clear the JavaScript Console in Google Chrome. We have various methods to clear the console; but our question is why do we need to clear the console?

Sometimes we have lots of commands and logs printed in any browser console which makes it look substandard and packed with output. So, we need to clear the console. And there are multiple ways to clear the console of google chrome.

Using the console.clear() method

This method will clear the console and display the message on the console that the console was clear.


Following is the example of the console.clear() method −

<!DOCTYPE html>
<html lang="en">
   <p>Please click the clear button to clear the console.</p>
   <button onclick="clearFunc()">clear</button>
      function clearFunc() {
  • We can also use the keyboard to clear the console. (Ctrl + L)

  • We can also use the clear log button on the top left corner of the chrome dev tools console to clear the console.

in the following screenshot, we have marked a circle on the clear log button.

  • On the macOS we can use (Command + k) for clear the log.