JavaScript Minifier

Make a script smaller and see how many bytes you saved. It leaves strings and regular expressions as they are.

JavaScript Minifier

Website Tools

Runs locally in your browser.

Your JavaScript is minified as text only — it is never executed. Strings, template literals and regular expressions are preserved exactly.

About the JavaScript Minifier

Modern websites are all about JavaScript-powered interactive experiences, which means they are more dependent on the size of JS files than ever before. Developers use whitespace and code comments to make their work easier, but browsers parse these symbols as unnecessary information

This JavaScript Minifier removes all extra whitespace and developer comments to make your code smaller in size. With this tool, you can optimize JS code to reduce its footprint on the server and accelerate page browsing.

Key Features of JavaScript Minifier

  • Intelligent and safe compression of JS codeall comments and whitespace are purged to reach the theoretical minimum size, leaving your strings, template literals, and regular expressions intact.
  • The minification process never executes your code to avoid potential security risks: your scripts are processed as plain text files in a sandboxed environment.
  • Track your optimization progress with this minifier’s real-time statistics: see how many bytes you’ve saved and what percentage of the file size was reduced after compression.
  • Process your JavaScript code locally in the browserthis way, your intellectual property is protected from being exposed to third parties on the server-side.
  • Export the minified file with just a click of a button. Choose between copying the compressed code to the clipboard or downloading a .js file to your computer.

How to Use JavaScript Minifier

  1. Open the JavaScript Minifier and paste the content to compress in the JavaScript source text area.
  2. Tick/cross the boxes next to Remove comments and Collapse whitespace to determine which elements to remove.
  3. Click the Minify button to perform the compression.
  4. Check the statistics at the bottom of the window: examine how many bytes and what percentage of the file size have been reduced.
  5. When you are satisfied with the result, click Copy to save the compressed code to your clipboard, or click Download to save the .js file to your computer. If you want to start over, click Clear.

JavaScript Minifier Examples

A comment and indentation removed. Variable names are not shortened.

Input
// total price
function total(items) {
  var sum = 0;
  items.forEach(function (i) {
    sum += i.price;
  });
  return sum;
}
Result
function total(items){var sum=0;items.forEach(function(i){sum+=i.price;});return sum;}

JavaScript Minifier — Frequently Asked Questions

What is JavaScript minification?
Minification is the process of reducing the file size of JavaScript code by removing all unnecessary whitespace and comments.
Will minifying break my regular expressions and strings?
No, the minifier processes your source code in such a way that the content of your strings, template literals, and regular expressions is left intact.
Is it safe to minify potentially unsafe code here?
Yes, because the content is processed as text and never executed as code.