1001Ferramentas
Dev

JS Minifier (basic)

Minify JavaScript by stripping line/block comments and extra whitespace. Works for simple code without full AST parsing.

Antes: 0 bytes · Depois: 0 bytes · Economia: 0%

Atenção: minificação simples sem AST. Pode alterar comportamento se houver ASI ou template literals complexos — teste sempre.

An honest cleanup, not a Terser replacement

Sometimes you just want the comments and indentation gone from a chunk of JavaScript: to inline it in a page, build a bookmarklet, or squeeze it into a character-limited field. Installing Node and configuring Terser for that is overkill. Here you paste the code and read the result instantly, with byte counts before and after so you can see exactly what the cleanup bought you.

The order of operations matters: the tool first shields strings, whether single-quoted, double-quoted or template literals, so it never deletes a // that lives inside text; only then does it strip line and block comments and squeeze out spaces and indentation. One deliberate detail: line breaks between statements are kept. That is what prevents JavaScript's automatic semicolon insertion, ASI, from changing your code's behavior when lines get joined.

Treat it as a cleanup, not real compression: with no syntax analysis, nothing gets renamed or rewritten, so the savings come from comments and whitespace alone. The page itself warns that edge cases can alter behavior; run the output or diff it before publishing anything. For production minification, Terser or esbuild do the full job with far bigger reductions. The code you paste never leaves your browser.

Frequently asked questions

Does this replace Terser or esbuild?
No. Those parse the code fully, shorten variable names and rewrite expressions, with much larger reductions. This tool covers the opposite case: a quick comment-and-whitespace cleanup with nothing to install.
Why does the output still have line breaks?
On purpose. Joining everything onto one line without understanding the syntax could trigger automatic semicolon insertion (ASI) and change the code's behavior; keeping the breaks is what makes the cleanup reasonably safe.
Can removing a comment take a URL from my code with it?
The rule that deletes line comments skips the :// pair so URLs are not cut, and strings are shielded before any removal. Still, test the result: the page warns the approach is simple and has edge cases.

Related Tools