JavaScript is often the heaviest part of a page, and scripts with comments and indentation slow down downloads and parsing. Our free JS Minifier is a conservative, safety-first tool: it tokenizes your code — understanding strings, template literals, and even regex literals — then strips comments and collapses whitespace without touching your logic. The space between two identifiers is always kept, newlines that automatic semicolon insertion depends on are preserved, and every semicolon stays put. No signup, runs fully in your browser.
Be aware of what this tool honestly is: a safe basic minifier. It does not rename variables or drop dead code the way a production build tool does — for that, use Terser or esbuild. What it gives you is a quick, reliable cleanup for snippets, bookmarklets, embed codes and small scripts, with byte counts and percentage saved shown for every run.
Paste the result into a Custom HTML block, a tag manager, or a .js file download, and test the page before shipping. For one-off scripts and experiments, it is the fastest path from readable to compact.
JS Minifier
Safely minify JavaScript — strips comments and whitespace without breaking code.
Safe basic minifier — it removes comments and extra whitespace only. It does not rename variables or perform advanced optimizations; for production builds use Terser or esbuild.
How to use
- Paste your JavaScript into the text box.
- Click Minify JavaScript.
- Check the original vs minified byte counts and the percentage saved.
- Click Copy Minified or Download .js.
- Test the minified script in a browser console or staging page before going live.
- Keep your readable original — minified code is for deployment, not editing.
FAQs
Does it rename variables like professional minifiers do?
No — and that is deliberate. This is a safe basic minifier: it removes comments and redundant whitespace only, with a tokenizer that understands strings, template literals and regex literals so it never breaks your code. It does not rename variables or eliminate dead code. For production builds with full optimization, use Terser or esbuild.
Can it break my script?
It is designed not to: whitespace between identifiers is preserved, ASI-sensitive newlines (like the one in “an++b”) are kept as newlines, and strings, template literals and regexes are copied verbatim. As with any transformation, test the output before deploying.
Why is the saving smaller than with tools like Terser?
Because this tool only removes comments and whitespace — typically 10–30%. Terser additionally shortens variable names and restructures code, which squeezes more but requires a build step. Use this tool for quick cleanups and Terser for production pipelines.