How to use it
- Paste your JavaScript into the input box. A full file or a small snippet both work.
- Press Minify to compress it, or switch to Beautify to reformat it with clean indentation instead. The output updates live as you keep typing.
- Check the stats line to see how many bytes you saved, then press Copy to grab the result.
How it works
Minifying makes a file smaller so it downloads faster and uses less bandwidth. This tool does it in two simple, reliable steps. First, it removes comments, both /* block comments */ and // line comments, since the browser does not need them to run your code. Second, it collapses runs of whitespace and newlines into single spaces and trims the edges, so all the indentation and blank lines that make code readable for humans are stripped out for the machine.
The byte sizes shown in the stats line are measured the same way a server would count them, so the percentage you see reflects the real saving on the wire.
A basic minifier, not a full compressor
This is a basic minifier. It removes comments and extra whitespace, but it does not rename variables, fold constants, drop dead code or do any of the deeper transformations a real compiler performs. For a production build you should use a full tool like Terser, which is built into most bundlers and compresses far more aggressively while keeping your code correct. Think of this tool as a quick way to trim a snippet, not a replacement for your build pipeline. Because everything runs locally, your code is never uploaded or sent anywhere.
Frequently asked questions
Is my code sent anywhere?
No, it is minified in your browser
Does it rename variables?
No, it only strips comments and extra whitespace. For that, use a full tool like Terser.
Will it break my code?
For most scripts the logic is unchanged, but always test the output before shipping.
How much will it shrink?
It depends on your comments and indentation. The stats line shows the exact saving.
Can it beautify my code instead?
Yes, click Beautify to reformat compressed or minified JavaScript with clean 2-space indentation instead of compressing it.
How much smaller will my file get?
It depends on how many comments and how much indentation your source has. Heavily commented, nicely indented code can shrink a lot, while already compact code shrinks only a little. The stats line shows the exact byte savings.
Does it rename variables like Terser?
No. This is a basic minifier. It removes comments and collapses extra whitespace, but it does not rename variables, fold constants or do dead code elimination. For production builds use a full tool such as Terser.
Is the minified code safe to run?
For most everyday scripts, yes. Because it only strips comments and extra spaces, the logic is unchanged. Always test the output before shipping, especially if your code relies on unusual formatting.
Why use this instead of a build tool?
It is handy for quick one-off jobs, like trimming a small snippet for an inline script or a demo, without setting up a build pipeline. For a real project, a bundler with Terser will compress far more.
Can it beautify JavaScript instead of minifying it?
Yes, click Beautify to reformat compressed or minified JavaScript with clean 2-space indentation instead of compressing it.
Related: JSON Formatter