Console Log Cleaner
Clean your production code by removing all console.log statements
Strip debugging output out of your JavaScript
Debug statements are useful while you build, but leftover console calls clutter the browser console, can leak internal details and add noise for other developers. This cleaner scans the code you paste and deletes the console statements it finds, then tells you how many it removed. It is meant as a quick pre-release pass for scripts, snippets and small files.
How to run it
- Paste your script into the JS Source Code box, or press Load Sample to try a small example. Clear empties the box.
- Choose a Cleaning Level from the dropdown. Full Sweep removes every listed console method, Only console.log() and Only console.debug() target a single method, and Only profiling removes console.time and console.timeEnd calls.
- Click Remove All Logs.
- The Cleaned Code panel shows the result with a count such as 3 Statements Removed. Use Copy to take the code.
What the Full Sweep covers
The full option matches log, debug, info, warn, error, table, dir, trace, time, timeEnd, group and groupEnd. That includes console.error and console.warn, so if your code uses those for real error reporting, choose one of the narrower levels instead.
When it is useful
- Tidying a script before pasting it into a CMS, a tag manager or a client project.
- Cleaning up a code sample before publishing it in a tutorial.
- Removing timing calls after you finish a quick performance check.
- Reviewing how many stray logs an inherited file contains.
Read this before trusting the output
The tool uses a pattern match on single lines, not a real JavaScript parser. Each match runs from console. to the end of the line, so anything after the call on the same line is removed with it, such as a second statement or a trailing comment. A console call that is spread over several lines is only partly removed and can leave broken syntax. Console text inside strings or comments is also matched, and removing a call that is the only body of an if statement without braces changes the logic of your code. Empty lines and indentation are left behind. Always read the cleaned code, run your tests, and keep the original. For serious production builds, a bundler option such as dropping console in your minifier is more reliable. The processing runs in your browser.
Related Tools