JavaScript Minifier

Compress JavaScript without corrupting what is inside the strings

Free Online JavaScript Minifier

A careless minifier is a bug generator: collapse the wrong whitespace and a string literal changes meaning. This minifier scans JavaScript token by token - string literals, template literals, and regexes pass through byte-for-byte, while comments and structural whitespace are stripped, and it reports exactly how much it saved.

  • Literal-aware scanning - string contents are never altered; "keep spaces" keeps both spaces
  • Regex vs division handled - the scanner distinguishes a regex literal from a division operator before deciding what is removable
  • Comments stripped - line and block comments are removed without eating the code around them
  • Size report included - every result states the before/after byte counts and the percentage saved
Open JavaScript Minifier

How to Minify JavaScript

  1. Open the JavaScript minifier
  2. Paste the JavaScript you want to compress
  3. Click "Convert" and check the reported size reduction
  4. Copy the one-line output wherever a compact script is needed

Example Conversion

Input (JavaScript):

// Calculate the total price
function calculateTotal(price, quantity) {
  const tax = 0.08;
  return price * quantity * (1 + tax);
}

console.log(calculateTotal(25, 4));

Output (Minified JavaScript):

function calculateTotal(price,quantity){const tax=0.08;return price*quantity*(1+tax);}console.log(calculateTotal(25,4));

The example drops from 169 to 120 bytes (29.0% smaller) - the converter reports this measurement on every run.

Common Use Cases

Embedding Snippets

Shrink a utility script before inlining it into a page or email client constraint.

Quick One-Off Compression

Minify a single file without setting up a bundler or build pipeline.

Safety Checks

Verify that minification does not change the strings and regexes in tricky legacy code.

Payload Trimming

Cut bytes from bookmarklets, snippets, and embedded widgets.

Related Tools