How to use the console.log remover
- Paste your code into the JavaScript box.
- Choose which calls to remove with the log, debug, info, warn and error boxes, or tick Every console method.
- Copy the Cleaned code or download it.
- Check the stats: Statements removed counts deleted calls, and Replaced with void 0 counts calls that had to stay as an expression.
What it does and when to use it
Debug logging piles up while you build a feature. Before a release, a code review or sharing a snippet, those calls leak data into the browser console and add noise for other developers. This tool removes them in one pass while leaving real error reporting in place, if you keep warn and error unticked.
It pairs well with the other clean-up tools. The JS comment remover strips comments the same careful way, and the JavaScript minifier shrinks the result. To see what your logs print before you delete them, try the JS console simulator.
How it works
The code is split into tokens by a lexer that understands strings, template literals, regular expressions and comments, so "console.log(1)" inside a string is never seen as a call. For each console.method( the tool finds the matching closing bracket, even across many lines. Then:
- If the call starts a statement, the call and its semicolon are removed. If nothing else is on that line, the whole line goes.
- If the call is part of an expression, it is replaced with
void 0so the code stays valid. - If something is chained after it, or it is a property such as
logger.console.log, it is left alone.
Worked examples
Default settings.
function save(user) {
console.log('saving', user);
const ok = db.put(user);
if (!ok) console.error('save failed');
console.debug("done");
return ok && console.info('saved') || ok;
}
becomes:
function save(user) {
const ok = db.put(user);
if (!ok) console.error('save failed');
return ok && void 0 || ok;
}
Two statements were removed and one call became void 0. The error call stays because error was not ticked.
Text inside a string. In const tip = "use console.log(x) to debug"; the string is kept exactly. Only the real console.log(tip); line on the next row is removed.
Arrow function body. With warn also ticked, items.forEach(i => console.log(i)); becomes items.forEach(i => void 0); and the console.warn('slow'); line is removed.
Limits and tips
- Aliases are not traced.
const log = console.log; log(x)orwindow.console.logare not recognised. - Arguments go too. If an argument had a side effect, such as
console.log(i++), that effect is removed with the call. - Empty blocks may remain.
if (debug) { console.log(x); }leaves an emptyif (debug) { }block, which is harmless but worth tidying.
Frequently asked questions
Why is a call replaced with void 0 instead of deleted?
Which methods are removed by default?
Will it break code that uses the return value of console.log?
Should I use this or a build setting?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.