Compress JavaScript by stripping comments and whitespace - safe, no mangling, free.
Input JavaScript
Minified Output
Original: 0 BMinified: 0 BSaved: 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
Strip comments - Removes // line comments and /* ... */ block comments (license blocks starting with /*! are preserved).
Collapse whitespace - Removes indentation and redundant spaces, keeping one space only where two words, numbers or operators would otherwise merge, as in return x or a - -b. A line break is kept wherever removing it could change how the code runs.
Respect strings - String literals, template literals, and regular expressions are left byte-for-byte identical. Code inside a template's ${...} is minified like any other code.
Conservative by design - No identifier renaming (mangling), no scope hoisting, no dead-code elimination. Code runs the same after minifying, whether or not it uses semicolons.
Byte savings - See original vs minified byte counts and percentage saved.
When you need a JS minifier
Production deploys - Smaller .js bundles download and parse faster, improving Time to Interactive.
Inline scripts - When embedding JS in HTML or email, every byte matters.
Scripts in user content - When a CMS stores JS in a database row and you need it compact.
Learning - Paste minified code and hit Beautify to see what a tool like Webpack actually ships to the browser.
How to use it
Paste a script into Input JavaScript, click Upload File to open a .js or .mjs file, or click Load Sample.
The minified code appears on the right as you type. Click Minify to refresh it.
Read the stats line to see the bytes saved.
Click Copy, or Download to save the result as minified.js.
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:
let a = 1 on one line and let b = 2 on the next stay on separate lines as let a=1 and let b=2.
a - -b becomes a- -b and a + +b becomes a+ +b, so they never turn into the -- and ++ operators.
A bare return with its value on the next line keeps its line break, so it still returns undefined. The same goes for break, continue, throw, and a line that starts with ++ or --.
A regular expression after return, typeof, an if (...) condition or inside ${...} is recognised as one, so its spaces are kept.
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.
By continuing, you agree to our
Terms of Use and
Privacy Policy,
and confirm you are at least 13 years old.
You're offline
Check your connection. This page will reload on its own the moment you're back online.
Trying to reconnect...
Choose an imageUpload a new picture, or pick one you have used before.
Drag a picture hereAdd a photo from your phone
JPG, PNG, WebP or GIF. Big photos are made smaller for you. You can also paste a picture. You can crop it next.
Uploading
That did not upload.
Drop to upload
Your pictures
No picture matches that name.
Crop imageDrag to reposition · zoom to crop, or fit the whole image