Utilzivo

JavaScript Minifier

Compress your JavaScript safely. This conservative minifier removes comments and unnecessary whitespace while carefully tracking strings, template literals, and regular expressions — so code like "http://example.com" is never corrupted by treating the // inside it as a comment. You see original vs. minified sizes with the percentage saved, and can copy or download the result. Everything runs in your browser.

How to Use the JavaScript Minifier

  1. Paste your JavaScript code into the input box.
  2. Click Minify JavaScript. Line and block comments are removed and whitespace is collapsed.
  3. Review the stats line to see how much smaller the file became.
  4. Copy the minified code or download it as a .js file.

Practical example

You wrote a 9 KB form-validation script with comments explaining each check. Minifying strips the comments and indentation, leaving a 5 KB file that behaves identically. You reference the minified file in your page, and it downloads and parses faster — while your commented original stays in your project for future maintenance. This workflow suits small sites perfectly: you get most of the performance benefit of a professional build pipeline with none of the tooling complexity, and re-minifying after every edit takes only a moment.

Key features and benefits

  • String-aware: single quotes, double quotes, and template literals are tracked, so // or /* inside strings is never mistaken for a comment.
  • Regex-aware: regular expression literals are detected and preserved, including escaped slashes and character classes.
  • ASI-safe spacing: spaces are kept wherever removing them could change meaning, such as between ++ operators.
  • Clear savings report: original bytes, minified bytes, and percentage saved on every run.
  • Private: minification happens locally — your code is never sent to a server.

Limitations

This is a conservative minifier: it does not rename variables or perform advanced optimizations, so files with very short code may shrink less than with an aggressive bundler. Extremely unusual syntax (such as regex literals directly after ) or }) may be misread — test the minified output in your browser before deploying. As always, keep the readable original and ship the minified copy. Also note that minified code is harder to debug, so during development always link the original file and switch to the minified version only for production.