Remove console.log statements

Paste JavaScript or TypeScript and strip the console.* calls you no longer want to ship. The scanner is token-aware, so a console.log inside a string, comment or regular expression is never touched, and calls used as a value are left alone instead of breaking your code. Runs in your browser; nothing is uploaded.

Try:
Cleaned source

About this tool

strip-console-logs deletes the console.* debug statements you accumulated while building a feature, so the source you ship no longer prints to the browser console. Paste JavaScript, TypeScript, JSX or TSX, choose which console methods to strip, and copy the cleaned source back out. Everything runs locally in your browser — the code you paste never leaves the page.

The scanner is token-aware rather than a regular expression. It walks the source tracking string literals, template literals, regular expressions and comments, so text that merely looks like a call — const s = "console.log(1)", // console.log(1), /console\.log\(/ — is left exactly as it was. Calls that span several lines, or that nest parentheses and strings inside their arguments, are matched as a whole.

Worked example

Input:

function checkout(cart) {
  console.log("cart", cart);
  let total = cart.reduce((a, i) => a + i.price, 0);
  console.debug(`total ${total}`);
  if (total > 100) {
    console.info("free shipping");
    total -= 5;
  }
  console.error("payment failed");
  return total;
}

With the defaults (methods = log,debug,info,warn, action = remove) the output is:

function checkout(cart) {
  let total = cart.reduce((a, i) => a + i.price, 0);
  if (total > 100) {
    total -= 5;
  }
  console.error("payment failed");
  return total;
}

console.error survives because it is not in the default method list. Set methods to all and keep to error,warn to invert that: strip every console call except the ones you still want in production.

Choosing what happens to each statement

Set Output to Dry-run report to see what would change without changing anything: the report lists the line number and text of every statement that would be removed, a per-method tally, and the calls the tool deliberately left in place.

Limits and edge cases

FAQ

Does it delete a console.log that is written inside a string or a comment?

No. The scanner tracks string literals, template literals, regular expressions and both comment styles, so only real calls in code positions are matched. A line such as const help = "call console.log(x) to debug"; comes back untouched, and so does // console.log(x).

How do I remove every console call except console.error?

Set Console methods to strip to all and Never strip these to error. The keep list wins over the method list, so it behaves like an exclude list. Add warn to the keep list too if you want warnings to survive the build.

Why is one of my console.log calls still there?

Because removing it would change behaviour. If the call is used as a value — assigned to a variable, an operand of &&, the body of an arrow function, or the start of a chain — the tool leaves it alone rather than silently altering the expression. Switch Output to Dry-run report and it will be listed under the "Kept" heading with its line number.

Can I keep the line numbers stable?

Yes. Choose Blank the line (keep line numbers) for the action. Each removed statement is replaced by the same number of blank lines it occupied, so line 200 is still line 200 afterwards. Choose Comment it out instead if you would rather keep the statement readable.

Does it work on TypeScript, JSX and TSX?

Yes. The scanner works at the token level, and type annotations, generics and JSX do not change how strings, comments or call parentheses are written, so .ts and .tsx sources are handled the same way as .js. It is not a type checker — it only rewrites the console statements it matches.

Is my source code uploaded anywhere?

No. The tool is compiled to WebAssembly and runs entirely inside your browser tab. The code you paste is never sent to a server, which also means it works offline once the page has loaded.

Developer & Automation Access

Run it from the terminal

Same engine as this page, headless — via the gizza CLI:

gizza tool strip-console-logs 'function checkout(cart) {
  console.log("cart", cart);
  return cart.length;
}'

New to the CLI? Get gizza →

Open it by URL

Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:

https://gizza.ai/tools/strip-console-logs/?code=function%20checkout%28cart%29%20%7B%0A%20%20console.log%28%22cart%22%2C%20cart%29%3B%0A%20%20return%20cart.length%3B%0A%7D&methods=log%2Cdebug%2Cinfo%2Cwarn&keep=error%2Cwarn&action=remove&remove_debugger=true&output=code

Machine-readable descriptor: tool.json — title + parameters JSON Schema for agents.