JavaScript Minifier
Strip comments and whitespace out of JavaScript to make it smaller and faster to download.
How it works
A compact workflow from input to download.
Paste your JavaScript
Drop in a script of any size.
Minify it
Comments and unnecessary whitespace are removed while the code's behaviour stays exactly the same.
Copy the output
Copy the minified script and keep your original source for editing.
Frequently asked questions
Does this mangle variable names?
How much smaller will my code get?
Will minified code still work?
Should I minify by hand for production?
Is my data sent to a server?
JavaScript is the most expensive thing you ship
Byte for byte, JavaScript costs a browser far more than any other resource. An image of a given size must be downloaded and decoded, and that is largely it. A script of the same size must be downloaded, parsed into a syntax tree, compiled, and then executed — and on a mid-range phone, that parse-and-compile step can take several times longer than the download did. This is why a site can score well on raw network metrics and still feel sluggish: the phone is not waiting for bytes, it is burning CPU on them. Reducing script size therefore pays twice, cutting both transfer time and processing time, and it is the reason performance work on modern sites so often reduces to shipping less JavaScript.
What a real minifier does that this does not
Stripping comments and whitespace is the easy half. A proper minifier parses the code into an abstract syntax tree and then applies transformations that require actually understanding the language: renaming local variables to single letters, since their names are invisible outside their scope; removing code that can be proven unreachable; inlining functions used only once; collapsing constant expressions; and shortening boolean and conditional constructs. Bundlers add tree-shaking on top, discarding exported functions that nothing imports. The combination routinely halves a bundle again beyond what whitespace removal achieves. The trade is that it must parse the language perfectly to stay safe, which is exactly why you use a well-tested tool for it rather than a regular expression.
Related tools
Continue the workflow with adjacent tools.