← All tools
// Code

JavaScript Minifier online

Minify JavaScript to reduce file size or beautify JS for readability

JavaScript Minifier logo
by
CHUNKY
MUNSTER
// Input JavaScript
0
Input bytes
0
Output bytes
-
Saved
// Minified output
Output will appear here...

Optimizing Scripts with the JavaScript Minifier

  1. Paste your JavaScript into the input panel.
  2. Click Minify to run the comment-strip and whitespace-collapse passes.
  3. Read the input bytes, output bytes and percent-saved figures below the buttons.
  4. Use Download .txt to save the minified output, or copy directly from the output panel.

JavaScript Minifier: compress your code by stripping comments and collapsing whitespace instantly. This js comment stripper uses a fast regex pipeline to drop block and line comments, providing a quick js compressor for prototyping and script optimization. It is an essential whitespace collapser for developers who need to shave bytes off their assets entirely in your browser.

How This Browser-Side JS Minify Tool Works

Our JavaScript Minifier functions as a technical regex minifier, performing two passes to tighten spaces around operators and punctuation. By providing real-time byte savings reports via TextEncoder, it simplifies the process of measuring the impact of your code shrink efforts. This free online tool ensures your logic stays private, offering a robust js shrink tool experience with no server-side logging or AST parsing overhead.

Frequently Asked Questions

Is this a real minifier like Terser or esbuild?

No. It is a fast regex-based pass that strips comments and collapses whitespace - useful for quick prototyping or shaving a few bytes off a snippet. For production code use Terser, esbuild or SWC, which understand the AST and can rename variables, remove dead code and preserve semantics around regex literals and template strings.

Will it break my code?

It can. Because there is no parser, edge cases like a regex literal containing // or a template literal with significant whitespace can be mangled. Always test the output in a browser before shipping it, or run a real minifier.

Why doesn't it rename variables?

Variable renaming requires scope analysis from a real parser. This tool deliberately does the cheapest 80%-of-the-savings transforms only - strip comments, drop whitespace - so it stays small and predictable.

What does the percent saved figure measure?

TextEncoder().encode(...).length on the input and output, so it is real UTF-8 byte size - the same number gzip will see before compression. Gzip usually compounds the saving by another 60–80%.

Enhance your delivery speed by using this JavaScript Minifier for all your quick script compression needs.

Bookmark this JavaScript Minifier for the next time you need to compress a script before shipping it to production.