JavaScript Minifier
Minify JavaScript by removing whitespace and comments
Input
Minified Output
Paste your input on the left and the result shows up here.
Or drop a file on this box, , or .
What is JavaScript Minifier?
Need to shrink your JavaScript file size? JavaScript Minifier removes comments and every bit of whitespace the parser does not need from your JavaScript code. Perfect for production environments where smaller file sizes mean faster page loads and better performance.
According to MDN Web Docs, minified JavaScript is functionally identical to formatted JavaScript but takes up significantly less space. Our minifier preserves all your code functionality while removing everything unnecessary. Great for production deployments, CDN hosting, or any scenario where file size matters.
Everything happens in your browser – your code never leaves your computer. Minify, download, and use your compact JavaScript right away. Learn more about JavaScript on Wikipedia or check out the official ECMAScript specification.
How to Use the JavaScript Minifier
The compact version is rebuilt every time the input changes, so the whole job is paste, glance at the right panel, take the result. You do not need semicolons everywhere first: where a statement ends on a line break, that line break is kept, because removing it would glue two statements together.
Paste, Upload, or Load Sample
Paste a commented, indented script into the input pane, or pick a .js file via Upload. Sample drops in a neatly indented helper that totals data usage, so you can watch the indentation collapse. Try it on a cart widget helper such as:
// Shipping cost for the cart widget
function shippingFor(order) {
/* free over 50 EUR */
if (order.subtotal >= 50) { return 0; }
return order.express ? 9.5 : 4.95;
} View Minified Output
The right panel shows the compact JavaScript. For the cart helper above that is function shippingFor(order){if(order.subtotal>=50){return 0;} on one line and return order.express?9.5:4.95;} on the next. The line break before return stays because the tool cannot tell whether the } before it closed a block or an object literal, and joining the lines is only safe in one of those two cases.
Download or Copy
Download saves the result as minified.js; Copy is quicker when it is going straight into an inline <script> tag. Run the copy once before you ship it. Clear wipes the input for the next file.
When You'd Actually Use This
Production Deployment
A static site with no build step, a CMS that only accepts a pasted script block, an email-capture widget for a client: places where wiring up a bundler is overkill and you just want the comments and indentation gone.
Performance Optimization
Reduce file sizes to improve page load speeds. Every kilobyte saved helps, especially on mobile devices or slow connections.
CDN Hosting
Save bandwidth costs by minifying JavaScript before uploading to CDNs. Smaller files transfer faster and cost less to serve.
Bundle Optimization
Minify JavaScript bundles to reduce overall application size. Works great with build tools or as a standalone step in your deployment pipeline.
Common Questions
Is my JavaScript code stored?
No. The minifier is a small tokenizer that runs in your own browser. There is no network call behind the output panel, and nothing you paste is saved.
Does minification break my code?
It should not. The code is split into tokens first, so only whitespace and comments go. A space stays wherever two tokens would otherwise merge (a - -1 keeps its space, a--1 would be a different program), and a line break stays wherever automatic semicolon insertion depends on it, so const a = 1 and const b = 2 on two lines do not become one broken line. Names are not shortened and nothing is rewritten, which also means it will not shrink as far as Terser.
How much smaller does it get?
It depends on how much whitespace and comments your JavaScript code has. Typically, you'll see 30-60% size reduction per web.dev performance guidelines, sometimes more for heavily commented code.
Can I format it back?
Yep. Use our JavaScript Formatter to make minified JavaScript readable again. Minification is reversible – formatting just adds whitespace back.
What about string literals?
Kept exactly as typed, and so are template literals, regex literals and JSX. A // inside "https://api.example.com" or inside /\/\// is part of the string or regex, not a comment, so nothing after it is cut.
Does it work with large files?
Mostly yes. The tokenizer makes one pass over the text, which a modern browser gets through quickly even at a few MB. The catch is that it reruns on every keystroke, so with a big file it is smoother to upload it than to edit it in place.
Other JavaScript Tools You Might Need
Minifying is the last step, so these are the tools you want before it (validate the syntax, tidy the source) and the one you reach for when you need to read the compact file again: