← All free tools Developer tools

JS minifier

Minify your JavaScript by removing all the unnecessary characters.

About this tool

The JS minifier makes JavaScript files smaller by removing comments, extra whitespace and line breaks, while keeping the code working exactly as before. It shows how much it saved, in percent and bytes.

How to use the JS minifier

  1. Paste your JavaScript.
  2. Press Minify.
  3. Copy the result into your site, or into a .min.js file.

What it does and doesn’t do

It removes comments and whitespace, and the line breaks and semicolons the code doesn’t need. It’s careful with strings, regular expressions and template literals, so their contents aren’t touched.

It doesn’t rename variables or rewrite your code, as bundlers like esbuild and Terser do. That makes the result a little bigger than theirs, but easy to read back and very unlikely to break anything.

Tips

  • Keep the readable original for editing, and minify a copy for the live site.
  • If it reports an error, the code has a syntax problem, such as a missing bracket.
  • On a larger project, a build tool like Vite minifies every file automatically each time you build.

Have a project in mind?

Have a brand or a product to grow?