JavaScript Minifier
Minify JavaScript code online to reduce file size. Remove comments and whitespace from JS files.
About this calculator
Paste JavaScript and minify it by removing comments and whitespace. Use it for small scripts, snippets and bookmarklets.
For large production bundles use a build tool; this page is for quick jobs.
How to use it
- Paste your JavaScript.
- Press Minify JavaScript.
- Press Copy.
What it does
This minifier removes comments and unnecessary whitespace. It does not rename variables or restructure code, so it is safe but gives smaller savings than a full tool such as Terser or esbuild. Always test the minified output, and keep your readable source.
Worked example
Before // add\nfunction add(a, b) { return a + b; }
| After | function add(a,b){return a+b;} |
Tips and common mistakes
- Missing semicolons can break minified code; add them first.
- Keep source maps in real projects.
- Test after minifying.
- Avoid minifying already minified files.
- Don't minify code with regular expressions or template strings you haven't checked.
Frequently asked questions
What does minifying JavaScript do?
Removes comments and whitespace to reduce file size.
Is it the same as obfuscation?
No.
Will it rename variables?
No, only whitespace and comments go.
How much will I save?
Typically 20 to 50%.
Does it work for ES6?
Yes for simple removal, but test the result.
Is it free?
Yes.