Free JavaScript Minifier

Compress JS in the browser: strip comments and tighten whitespace. Quick byte stats — not Terser; test before production.

Sample JS

About JavaScript Minifier

Regex pipeline: removes `//` and `/* */` comments, collapses whitespace, tightens punctuation. Not Terser, esbuild, or SWC.

How it works (technical)

Steps: `replace(/\/\/.*$/gm,'')` → block comments → `replace(/\s+/g,' ')` → `replace(/\s*([{}();,:])\s*/g,'$1')` → `replace(/;\s*}/g,'}')` → trim.

No AST walk, no rename, no DCE — template literals and ASI edge cases can break naive output; test before production.

Byte counts from `Blob` length; no server upload.

When to use it

  • Comment-heavy snippets

    Estimate byte savings when formatting and comments dominate the file.

  • Demos and gists

    Quick one-off minify when a full bundler is overkill.

  • Pair with formatter

    Use the JS formatter when you need readable source again.

How to Use JavaScript Minifier

  1. 1Paste your JavaScript code into the input area.
  2. 2Click the "Minify JavaScript" button to compress your code.
  3. 3Review the compression statistics.
  4. 4Copy the minified JavaScript for your project.

Key Features

  • Custom regex pipeline (see technical details)
  • Original / minified bytes + percent saved
  • Copy output

Benefits

  • Instant size readout
  • Runs fully client-side
  • Works alongside the JS formatter

Frequently Asked Questions

Will minification break my JavaScript?

Basic minification (removing whitespace and comments) is safe. However, for complex code, always test the minified version before deploying to production.

How much can I reduce my JS file size?

JavaScript files typically reduce by 30-50% after minification, depending on the amount of comments and formatting in the original code.

What's the difference between minification and obfuscation?

Minification removes unnecessary characters to reduce file size. Obfuscation transforms code to make it harder to read and reverse-engineer. This tool only performs minification.

Related Tools