JavaScript

JavaScript Minifier

Details

How to use JavaScript Minifier

What the tool does, how to run it, and what to expect from the result.

How to minify JavaScript

Minifying JavaScript removes comments and collapses whitespace, producing a smaller file that behaves the same. It is a quick way to shrink an inline script or a small snippet without setting up a toolchain.

The transform runs in your browser. It is a scanner rather than a full parser: strings and template literals are protected, comments are dropped, and whitespace outside them is collapsed. That design is what makes it instant and also what sets its limits.

  • Paste your JavaScript into the input box.
  • Confirm your code terminates statements with semicolons, because newlines are collapsed and code relying on automatic semicolon insertion will break.
  • Read the minified output and compare the byte counts.
  • Diff the output against the input if the code contains regular expression literals, since those are not tracked by the scanner.
  • Run the result before you ship it, and for anything going to production, use esbuild or terser in your build pipeline instead, so you get identifier renaming and a source map.
Tips

Getting a better result out of JavaScript Minifier

Specific settings and thresholds, not general advice.

  • Code without semicolons is safe. Line breaks are preserved, so automatic semicolon insertion still applies and a StandardJS or Prettier-no-semi codebase is not glued into one broken line.
  • Regular expression literals are safe. The scanner has a separate state for them, so a pattern containing slashes, such as a URL matcher, is not mistaken for a comment.
  • It removes whitespace and comments, and that is all. It does not rename variables, drop dead code, inline constants, or tree-shake unused imports, which is where a real minifier gets most of its savings. Expect roughly 30 to 40% off, where esbuild or terser would take 60% or more.
  • Minification is a build step, not a manual one. Pasting code into a web page cannot be part of your CI pipeline, cannot generate a source map, and cannot be repeated reliably. If you are shipping JavaScript to production, wire esbuild, terser, or your bundler into the build instead.
  • Gzip and brotli have already taken most of the whitespace. Compression handles repetition brilliantly, so the marginal benefit of stripping spaces from an already-compressed response is small. The savings that survive compression are the ones minification alone cannot make: shorter identifiers and deleted code.
Limits

What JavaScript Minifier does not do

The honest boundary, so you do not lose time finding it yourself.

  • It does not rename variables or shorten identifiers, so it saves far less than esbuild or terser.
  • It does not parse your code into a syntax tree, so it cannot remove dead code or fold constants.
  • It does not rename identifiers, remove dead code, or tree-shake, so it saves far less than a real minifier.
  • It produces no source map, so a stack trace from the minified code cannot be mapped back to your original lines.
At a glance

Who JavaScript Minifier is for

A quick way to understand who this helps, what it solves, and where it connects next.

Best fit

Developers and anyone working with code who needs quick formatting.

Ideal for

Quickly minify JavaScript without a build step or install.

FAQ

Common questions

Short answers for the questions people usually have before trying a utility like this.

Is it safe on code that omits semicolons?

Yes. Newlines are kept, which is what automatic semicolon insertion depends on. Only indentation, comments and redundant spacing are removed, so a semicolon-less file still parses.

Should I minify by hand, or in my build?

In your build, always. A minifier pasted into a browser cannot run in CI, cannot emit a source map, and cannot be applied consistently to every file in a project, which means the version you ship drifts from the version you tested. esbuild does this in milliseconds, terser does it thoroughly, and every bundler has it built in. A web-based minifier is for inspecting a snippet or squeezing an inline script, not for producing a release.

How much smaller will my file get?

Enough to matter for a snippet and not enough to matter for a bundle. Only whitespace and comments are removed, so expect a modest saving. A real minifier renames variables and removes dead code, which is where the big numbers come from.

Does it handle template literals and strings correctly?

Strings and template literals are tracked properly: the scanner recognises the opening quote or backtick, honours backslash escapes, and copies the contents through untouched, so a brace or a slash inside a string is never treated as code. Regular expression literals are the gap. They are not tracked, and a pattern containing slashes can be mistaken for a comment. If your code has regexes, diff the output before you use it.

Is my code uploaded?

No. The minification is a local scan over the text in your browser. Nothing is transmitted or stored, which matters if the code is proprietary or unreleased.

Recommendations

You Might Also Like

Nearby tools from the catalog that fit the same job or workflow.

Cleanor app

Do it all on your device

Cleanor puts these tools in one app: compress and convert images, video, and audio, work with PDFs, and scan text right on your device. Plus free up storage and clear inbox clutter with Email Cleaner. Start with a free trial.

  • iPhone
  • Android
  • Macsoon
  • Windowssoon