JavaScript Minifier

Compress JavaScript by stripping comments and whitespace - safe, no mangling, free.

Input JavaScript
Minified Output
Original: 0 B Minified: 0 B Saved: 0.0%

JS Full Form

JS is short for JavaScript - the programming language of the web browser. JS source files are written with generous indentation, comments, and line breaks that the JavaScript engine parses and then discards. Minification strips those tokens so your browser downloads and parses a smaller file, improving page load time.

What this tool does

When you need a JS minifier

How to use it

  1. Paste a script into Input JavaScript, click Upload File to open a .js or .mjs file, or click Load Sample.
  2. The minified code appears on the right as you type. Click Minify to refresh it.
  3. Read the stats line to see the bytes saved.
  4. Click Copy, or Download to save the result as minified.js.
  5. Before you ship it, run the minified file once in the browser console or your test page to confirm it still works.

A worked example

This 167-byte snippet, written over several lines with two comments:

// Add GST to a price
function withGst(price, rate = 18) {
  /* rate is a percentage */
  return price + (price * rate) / 100;
}
console.log(`Total: ${withGst(500)}`);

becomes 102 bytes, about 39% smaller:

function withGst(price,rate=18){return price+(price*rate)/100;}
console.log(`Total: ${withGst(500)}`);

The space between return and price is kept because the two words would otherwise merge into one name, while the spaces around +, = and the brackets are removed. The text inside the template literal, including the space after the colon, is left exactly as written. The line break after the closing brace stays: a brace can end an object as well as a function, and in code without semicolons that line break is what ends the statement. It costs one byte, the same as a space.

Code without semicolons

JavaScript lets you leave semicolons out and relies on line breaks instead. The minifier follows the same rules, so it only removes a line break when the statement clearly carries on, for example when the line ends with a comma, an operator or an opening bracket, or the next line starts with a dot, a closing bracket or an operator:

For production bundles a parser-based tool such as Terser or esbuild will still give smaller output, because it also renames variables and removes code that never runs.

Privacy

Everything runs locally in your browser. Your JavaScript is never sent to our servers, not even for analytics. You can minify proprietary business logic, unreleased features, or internal tooling without anything leaving your machine.

Frequently Asked Questions

Does this tool mangle (rename) my variables?
No. Mangling is the aggressive technique of renaming myLongVariableName to a to save bytes. It requires full scope analysis and can break code that relies on reflection or dynamic lookup. This tool deliberately does not mangle - your identifiers stay exactly as you wrote them.
Is it safe to run on any JavaScript?
Yes. It respects strings, template literals with ${...}, regex literals and comments, keeps a space wherever two tokens would merge (return x, a - -b, a + +b), and keeps a line break wherever removing it could change how the code runs, so code without semicolons works too. For the smallest production builds, a parser-based tool such as Terser also renames variables and removes dead code.
How much can I realistically save?
Hand-authored JS shrinks by 30-50% from whitespace and comment stripping alone. Aggressive minifiers like Terser add another 10-20% through mangling and dead-code elimination. After gzip the wire savings are smaller but still real.
Should I use this or Terser/esbuild/UglifyJS?
For a one-off minify of a self-contained script - this tool, in seconds. For a build pipeline shipping a bundled app to production - use terser or esbuild: they parse to an AST, mangle safely, eliminate dead code, and produce the smallest possible output.
Is my JavaScript uploaded anywhere?
No. All minification happens in your browser. Nothing is sent to our servers, logged, or cached anywhere except the current browser tab.
Can I reverse the minification?
Click Beautify to add newlines after ; and {. It's not a full reformatter - for proper indentation and spacing, run the output through Prettier or your editor's format-on-save.