ZeroFee Tools
Free JavaScript minifier tool cover

A JavaScript minifier is a free online tool that shrinks JS code by removing comments and collapsing unnecessary whitespace. This is a basic minifier: it safely strips comments and extra spaces while protecting strings, and shows before/after byte sizes. It is not a production-grade minifier like Terser: it does no variable renaming or dead-code elimination.

Honest note: this is a basic minifier. It removes comments and extra whitespace, which typically saves 15-30%. It is not a full production minifier like Terser: it does not rename variables, remove dead code, or optimize logic. For production bundles, use Terser or esbuild.

How do I minify JavaScript online?

Paste your script and press Minify. Comments are stripped, whitespace is collapsed, and strings are protected so your code keeps working. The stats row shows exactly how many bytes you saved, and Copy output grabs the result.

This basic approach is safe for typical scripts: a state machine walks the code, skipping over string literals so quotes and template literals survive intact, while // and /* */ comments are removed. Punctuation spacing is tightened without touching identifiers or keywords.

Is this a replacement for Terser or esbuild?

No. This is a basic minifier: it removes comments and extra whitespace only. Terser and esbuild go much further with variable renaming, dead-code elimination, and syntax transforms that typically cut another 20-40%. Use this tool for quick wins and a real bundler for production.

One more honest limit: regex literals containing significant spaces (for example /a b/) can be altered by whitespace collapsing, and very unusual syntax may confuse the simple parser. Always test minified output before deploying it.

Frequently asked questions

Is this JavaScript minifier free?

Yes. Minify unlimited JavaScript with no account and no limits. It runs entirely in your browser.

What does "basic minifier" mean exactly?

It removes comments and collapses unnecessary whitespace, and nothing else. There is no variable renaming, no dead-code removal, and no syntax optimization, which is what tools like Terser add.

Will minifying break my code?

For typical scripts, no: strings are protected and only safe whitespace is removed. Regex literals with meaningful spaces are the main edge case, so test the output before shipping it.

How much smaller will my file get?

Comment and whitespace removal usually saves 15-30%, depending on how heavily commented and formatted the source is. The tool reports the exact saving for every run.

Is my code uploaded anywhere?

No. Minification happens locally in your browser. Your code never leaves your device.