About the JS Minifier
The JS Minifier shrinks JavaScript by deleting comments, collapsing whitespace and removing spaces around punctuation, while keeping strings and template literals exactly as written. It keeps the line breaks JavaScript needs for automatic semicolon insertion, so code without semicolons still works.
How it works
The tool scans the code once, setting aside strings and template literals so nothing inside quotes changes, and dropping /* */ and // comments. It then collapses whitespace, removes spaces next to punctuation such as { } ( ) ; , : = < > * / & | ! and ?, and keeps a line break wherever JavaScript's automatic semicolon insertion might need one.
This is a lightweight scan, not a full parser. It understands strings, template literals and comments, but not regular expression literals, and it does not rename variables or remove dead code the way production tools such as Terser or esbuild do. Test the output, especially if your code contains regex literals with quotes or slashes.
How to use
- 1
Paste your JavaScript into the input box, or click Open file.
- 2
Review the minified output and the size cards.
- 3
Copy or download the result, then test it before using it.
Worked examples
A small function with comments
You want a compact version of a helper function to paste inline.
Both comments are removed, the line breaks collapse, and spaces around the comma, braces and + are dropped. The input is 81 characters and the output is 30, so the tool reports 51 saved (63%).
Frequently asked questions
Is minified JavaScript still readable?+
Not easily. With comments and most line breaks gone, the code is packed onto very few lines. Keep your original source file for development and only use the minified copy where size matters.
Can minifying JavaScript break my code?+
With this tool, yes, in some cases. It works with text patterns rather than a JavaScript parser, so URLs in strings, code without semicolons, and expressions like a - -b can be altered. Always test the output.
Does it shorten variable names?+
No. It only removes comments and whitespace. Renaming variables (mangling) requires a full parser, which build tools like Terser and esbuild provide.
How much smaller will my file get?+
It depends on how much of the file is comments and indentation. Heavily commented, well-indented code often shrinks by 30 to 60 percent; already compact code shrinks much less. The tool shows the exact saving for your input.
Is my code uploaded anywhere?+
No. The minification is done by JavaScript running in your browser tab.