Js Minify
Compress code, remove comments, download .js files instantly. Fast tool to boost site speed.
What is This Tool
The JavaScript Minifier compresses your JS files by removing comments, collapsing whitespace, and optionally shortening variable names — producing smaller, faster-loading scripts without changing how they run. Smaller JavaScript files reduce page load time, lower bandwidth usage, and improve Core Web Vitals scores like Time to Interactive (TTI) and Total Blocking Time (TBT).
Everything runs directly in your browser. Your code is never uploaded to a server, making this tool safe for proprietary scripts, internal tooling, or any code you'd rather keep private. It handles modern ES6+ syntax including arrow functions, template literals, destructuring, async/await, and class definitions.
How to Use
Minifying your JavaScript takes just a few steps:
- Paste your code — Drop your JavaScript into the "Source JavaScript" panel on the left. The tool processes it automatically as you type or paste.
- Choose your options — "Remove Comments" and "Collapse Whitespace" are enabled by default and are safe for all scripts. Enable "Mangle Variable Names" for additional compression, but test the output before deploying — it renames local variables to shorter identifiers, which can cause issues if your code relies on function or variable names at runtime.
- Review the output — The minified result appears instantly in the right panel. The stats bar shows original size, minified size, and how much space was saved.
- Copy or download — Click "Copy to Clipboard" or click anywhere in the output panel to copy the minified code. Use "Download .js" to save it as a file.
- Clear and repeat — Hit "Clear All" to reset both panels when you're ready to process another file.
Key Features
- Real-time minification — Output updates instantly as you type or paste, with no button press required.
- Comment removal — Strips both single-line (
//) and multi-line (/* */) comments, including JSDoc blocks. - Whitespace collapsing — Removes unnecessary spaces, tabs, and line breaks while preserving string contents and avoiding syntax errors.
- Variable name mangling — Renames local variable and function identifiers to single characters for maximum compression. Works best on self-contained scripts without external dependencies.
- String preservation — Keeps the contents of string literals intact so URLs, messages, and data values are never accidentally modified.
- Live size stats — Displays original size, minified size, and percentage savings in real time so you can see the impact immediately.
- One-click copy and download — Copy to clipboard or download the minified output as a
.jsfile with a single click. - Fully client-side — No server uploads, no accounts required. Your code stays in your browser.
Common Use Cases
JavaScript minification is valuable across a wide range of development and deployment scenarios:
- Production deployment — Convert readable, commented development scripts into compact production files before shipping to staging or live environments.
- Improving Core Web Vitals — Smaller JS files reduce Time to Interactive and Total Blocking Time, which directly affect Google Lighthouse scores and search rankings.
- WordPress and CMS themes — Minify custom scripts added to themes, plugins, or page builders to reduce overall page weight without changing behavior.
- Reducing CDN and bandwidth costs — Smaller assets mean fewer bytes transferred on every page load, which adds up quickly on high-traffic sites.
- Mobile performance — Compact scripts parse and execute faster on lower-powered devices and cellular connections.
- Single-file utilities and bookmarklets — Compress self-contained scripts to the smallest possible size for embedding or sharing.
Frequently Asked Questions
Will minifying JavaScript break my code?
Not if you stick to "Remove Comments" and "Collapse Whitespace" — those operations are safe for virtually all JavaScript. "Mangle Variable Names" carries more risk: it renames local identifiers, which can break code that uses eval(), depends on Function.name, or accesses variables dynamically. Always test minified output before deploying.
Does this tool support modern JavaScript (ES6+)?
Yes. The minifier handles modern ECMAScript syntax including arrow functions, template literals, destructuring assignments, spread operators, async/await, optional chaining, and ES6 class definitions.
Is my code sent to a server?
No. All processing happens locally in your browser using JavaScript. Nothing is transmitted or stored on any server. It's safe to use with proprietary, confidential, or unreleased code.
Can I get my original code back after minifying?
No — minification is a one-way process. Comments and formatting are permanently removed, and mangled variable names cannot be reliably restored. Always keep your original source files in version control and only minify when generating production builds.
How much size reduction should I expect?
Most scripts see a 20–40% reduction from whitespace and comment removal alone. Enabling variable mangling can push that to 50% or more on larger files. Combining minification with Gzip or Brotli compression on your server typically achieves 70–85% total transfer size reduction.
When should I use this tool vs. a build tool like Webpack or Vite?
This tool is ideal for quick one-off compressions, checking how much a file can be reduced, or when you don't have a build pipeline configured. For large-scale projects with multiple files, imports, and CI/CD workflows, integrating a bundler with built-in minification (Terser via Webpack, esbuild via Vite) is more practical and handles module dependencies correctly.
Advanced Tips
Get more out of your JavaScript optimization workflow with these practical techniques:
- Keep source files in version control — Store your readable, commented source as
app.jsand commit only that. Generateapp.min.jsat build time or manually before deploying. - Combine files before minifying — Merging multiple scripts into one before minification reduces HTTP requests and can unlock additional compression from removing repeated boilerplate across files.
- Be cautious with variable mangling and global scope — Mangling is safest on self-contained functions. If your script exposes global variables or integrates with third-party libraries that reference identifiers by name, disable mangling to avoid runtime errors.
- Layer on server-side compression — Minified JavaScript is already smaller, but enabling Gzip or Brotli on your web server or CDN compresses it further — often achieving an additional 60–75% reduction in transfer size.
- Use source maps for debugging — If your build pipeline supports it, generate a source map alongside your minified output. This lets browser DevTools map minified code back to the original source during debugging, without serving unminified JS in production.
- Remove dead code before minifying — Tree-shaking tools like Rollup or Webpack can eliminate unused functions and imports before minification, resulting in a smaller starting point and a more aggressively compressed final output.