Free JavaScript Minifier
This free JavaScript minifier removes comments and unneeded whitespace from your code and shows the size before and after. It reads strings, template literals and regular expressions as units so their content is never changed, and it keeps line breaks that automatic semicolon insertion may need. It is a conservative whitespace tool, not a full compiler: it does not rename variables or rewrite code.

JavaScript Minifier
Generators and Converters
About this tool
JavaScript is often the heaviest part of a page, and every kilobyte has to be downloaded, parsed and run. Removing comments, indentation and blank lines is the safest first reduction, because it changes only characters the engine ignores.
This tool walks through the code one token at a time. Single-quoted, double-quoted and template strings are copied as they are, regular expression literals are recognised from the token before them, and a space is kept only where removing it would join two words or two plus or minus signs. Line breaks are kept where code may rely on automatic semicolon insertion, so code written without semicolons still behaves the same.
Please read the limits: this is not a full compiler. It does not shorten variable names, drop dead code or understand every edge of the language, so very unusual code should always be tested after minifying. For production bundles, use a build tool such as Terser and treat this page as a quick helper for snippets and small scripts. Nothing you paste is stored.
Frequently asked questions
Is this a full JavaScript compiler?
No. It removes comments and whitespace only, and it does not rename variables, remove unused code or transpile modern syntax. That keeps the output predictable. For a production bundle, use a build tool such as Terser or esbuild, which can shorten names as well.
Why are some line breaks kept?
JavaScript can insert semicolons automatically at line ends, so deleting every line break could join two statements and change what the code does. The minifier keeps a line break wherever it is not clearly safe to remove it, which costs a few bytes but avoids bugs.
Will it break regular expressions or strings?
It treats quoted strings, template literals and regular expression literals as units and copies them exactly. A slash is read as a regular expression when it follows an operator or opening bracket, and as division after a value. Test the result once if your code uses unusual patterns.
How much smaller will my script be?
Well commented, nicely indented code can shrink by a third or more, while code that is already compact shrinks very little. The result panel shows the exact bytes before and after, so you can judge the saving for your own script.
