Developer

JavaScript Minifier

Trim comments and unnecessary blank lines from a JavaScript file to reduce its size.

This is a light, comment/whitespace-only minifier. It doesn't rename variables. Always test minified output before deploying it.

How to use the javascript minifier

  1. Paste your JavaScript into the input box.
  2. Click Minify.
  3. Copy or download the result, and test it before deploying.

Features

  • Strips block and line comments
  • Removes blank lines and leading/trailing whitespace per line
  • Copy or download as a .js file

What this JavaScript minifier is for

This tool is intended for light client-side minification: removing comments and avoidable whitespace to make straightforward scripts smaller. It is not a full compiler, bundler or optimiser and does not perform advanced transformations such as tree shaking.

Always keep the readable source version and test the minified output. Complex regular expressions, template-generated code or unusual syntax are safer with a production build tool such as a dedicated JavaScript minifier integrated into your project.

If a script is part of a larger application, source maps and a proper build step make production errors easier to diagnose. A quick browser minifier is better suited to small standalone snippets than a full application bundle.

Frequently asked questions

No. This is a light, safe minifier that only removes comments and extra whitespace — it won't shorten variable names or restructure logic the way a full bundler minifier (like Terser) does.

The comment stripper uses a straightforward pattern match; in rare cases, a // or /* inside a string or regular expression could be misread. Always test the minified output before using it in production.

Keep a debuggable JavaScript source

Minification makes production files smaller but harder to inspect. Maintain the readable source separately, and test the minified result because aggressive transformations can expose assumptions that were hidden during development.

  • Run your normal functional tests after minifying.
  • Keep source maps when practical.
  • Use HTTP compression and caching as well; minification is only one part of delivery optimisation.

Related reading: What “runs in your browser” means for privacy