Remove all console.log statements at once

  1. Open the global search and replace function in your editor.
  2. Enable the Regular Expression (Regex) mode by clicking the .* icon in the search bar.
  3. In the Find input field, use one of the following regular expressions:

console\.log\(.*\);? (for single-line console.log statements)

console\.log\(([^)]+)\);? (for single or multi-line statements)

console\.(log|warn|error|info)\(.*?\);? (to target all console methods)

  1. Leave the Replace input field empty to delete the matches.
  2. Click the “Replace All” button.

Loved this post?

Comments

Interested in
working
with me?