Back to Tools

JavaScript Minifier

JavaScript Minifier

Reduce JS file size by removing comments and whitespace

JavaScript Tool
Source Script
Compressed Code

                

About the JavaScript Minifier

Shrink JavaScript by removing whitespace and comments so pages load faster.

How to use the JavaScript Minifier

  1. Paste your code into the input box, or click Load Sample to load an example.
  2. Under Advanced Options, choose Mangle Variables (experimental), Remove console.* Logs or Remove All Comments.
  3. Press Minify JavaScript.
  4. Use Copy (or Download where shown) to keep the result. Clear empties the box.

When to use the JavaScript Minifier

  • Shrinking a script before you upload it to a small site that has no build tool.
  • Reducing the size of inline scripts and bookmarklets.
  • Checking how much whitespace and comments add to the size of your code.
  • Producing a quick production copy of a small library or snippet.

Common mistakes to avoid

  • Turning on variable mangling for code that reads its own function or property names, such as code that uses eval or string-based access. It can break the script.
  • Overwriting the only copy of your source. Always keep the readable version for future edits.
  • Skipping tests after minifying. Missing semicolons in the original code can behave differently once line breaks are removed.

Tips

  • Test minified code before you deploy. Variable mangling is experimental and can break some scripts.
  • Keep your original, readable source file.
  • Enable gzip or Brotli compression on your server too. Compression saves much more than minifying alone.
  • For bigger projects, use a build tool such as esbuild, Terser or your framework's bundler.

Frequently Asked Questions

Usually 20% to 60% depending on how many comments and how much whitespace it has.
Usually 30% to 60% for readable code with comments. Code that is already compact saves less.
No. Minifying makes the file smaller. Obfuscation deliberately makes the code hard to understand. Neither one protects secrets.
No. A smaller file downloads faster, which usually makes pages load quicker.
Live Support
We usually reply within minutes

Enter your name to start a conversation with our team.