Temp Mail Logo

Temp Mail safeguards your privacy while keeping your inbox free from spam.

⚡ Powered by Terser · Mangle · Compress · Dead Code Removal

JavaScript Minifier

Professional online JavaScript minifier powered by Terser 5 -- the same engine trusted by webpack, Vite, and Rollup. Get real variable mangling, dead code elimination, and multi-pass compress optimization. Free JS minifier that runs 100% in your browser -- your code never leaves your machine.

✓ Powered by Terser 5✓ Variable mangling✓ Dead code removal✓ Drop console option✓ 100% client-side
Loading Terser...
Input JavaScript
Minified Output
Minified output appears here as you type...
What this tool does

Professional JavaScript Minification Powered by Terser

How this free online JS minifier works and why it produces the smallest possible output

This free online JavaScript minifier uses Terser 5 -- the same minification engine built into webpack, Vite, Rollup, Parcel, and esbuild -- to compress your JS code directly in your browser. Unlike regex-based tools that simply strip whitespace and line breaks, Terser parses your code into a full Abstract Syntax Tree (AST) before making any transformations. This means it handles every edge case correctly: strings containing operator characters, regex literals that look like comments, template literals, computed property names, and complex destructuring patterns all minify accurately every time. The result is guaranteed to be semantically equivalent to your input -- same behavior, drastically smaller footprint.

JavaScript minification is a multi-stage process. The first stage strips whitespace, newlines, and comments -- producing immediate size savings with zero risk. The second stage, variable mangling, renames local variables and function parameters from descriptive names like userAccountBalance to single characters like a. Because JavaScript scoping is analyzed at the AST level, there is no risk of naming collisions between different scopes. The third stage, compression, performs advanced static analysis: dead code that can never execute is removed, constant expressions like 2 * 1024 are pre-evaluated and replaced with their numeric result, and multiple passes ensure every possible optimization is applied. These three stages together commonly reduce file size by 50 to 70 percent.

Minifying JavaScript is one of the highest-leverage performance optimizations available to web developers. Smaller JS files download faster, parse faster, and compile faster -- directly improving Core Web Vitals metrics like Time to Interactive (TTI) and Largest Contentful Paint (LCP). For mobile users on slower connections, the difference between a 200KB and an 80KB script can be several seconds of load time. This tool is ideal for minifying standalone scripts, auditing what Terser does to a specific code pattern, verifying compressed file size before deployment, and quickly compressing vendor code that is not part of a build pipeline. Your code is never transmitted to any server -- everything runs locally in your browser.

Terser 5 Engine
The same minifier used by every major JS bundler. Parses real ASTs, not regex.
Variable Mangling
Renames locals to a, b, c -- significant savings on top of whitespace removal.
Dead Code Elimination
Removes unreachable branches, unused variables, and constant-false conditionals.
Constant Folding
Evaluates static expressions at compile time: 60 * 60 * 24 becomes 86400.
Drop console.*
Removes all console.log/warn/error calls for clean production bundles.
Top-Level Mangling
Also renames module-level globals -- ideal for fully bundled scripts.
License Preservation
Retains /*! comment blocks so license headers survive minification.
Multi-Pass Compress
Runs 2 optimization passes to ensure maximum reduction without errors.
100% Client-Side
Terser runs in your browser. Your source code is never uploaded anywhere.
Real-Time Output
Minified result updates automatically with a 600ms debounce as you type.
Examples

JavaScript Minification Examples -- Before and After

Real-world code scenarios showing what Terser does with different option combinations
ExcellentFull Terser pipeline -- compress + mangle + drop console
Input
function calculateTotal(cartItems, taxRate) { console.log('Calculating total for', cartItems.length, 'items'); var subtotal = 0; var dead = false; if (dead) { console.log('never runs'); } for (var i = 0; i < cartItems.length; i++) { subtotal += cartItems[i].price * cartItems[i].qty; } return subtotal * (1 + taxRate); }
Output
function calculateTotal(a,b){var c=0;for(var d=0;d<a.length;d++)c+=a[d].price*a[d].qty;return c*(1+b)}
With all options enabled, Terser removes the dead branch, strips all console calls, renames parameters and locals to single characters, and eliminates whitespace. The result is a ~75% smaller function that behaves identically. This is the recommended configuration for any production build.
GoodCompress + mangle, console calls preserved
Input
function logEvent(eventName, payload) { console.log('[Analytics]', eventName, payload); var timestamp = Date.now(); var entry = { name: eventName, data: payload, ts: timestamp }; return entry; }
Output
function logEvent(a,b){console.log("[Analytics]",a,b);var c=Date.now();return{name:a,data:b,ts:c}}
When Drop console is disabled, all console calls are preserved in the output. Terser still renames parameters and locals and removes unnecessary intermediate variables. This configuration is ideal for analytics or SDK code where console output is intentional and meaningful to the developer using the library.
GoodWhitespace + comments only -- mangle disabled
Input
/** * Validates an email address using a regex pattern. * @param {string} email - The email to validate * @returns {boolean} */ function validateEmail(email) { // Standard RFC 5322 simplified pattern var pattern = /^[^s@]+@[^s@]+.[^s@]+$/; return pattern.test(email); }
Output
function validateEmail(email){var pattern=/^[^s@]+@[^s@]+.[^s@]+$/;return pattern.test(email)}
With mangle disabled, variable names remain unchanged -- useful for libraries that may be read or debugged by third-party developers. Comments (except license blocks starting with /*!) are still removed. This is a good middle ground between readability and file size reduction for public-facing JavaScript libraries.
FairCompress only -- dead code and constants folded
Input
var DEBUG = false; var MAX_RETRIES = 3; var BASE = 10; var FACTOR = 5; var RESULT = BASE * FACTOR; function retry(fn) { if (DEBUG) { console.log('Debug mode active'); } for (var i = 0; i < MAX_RETRIES; i++) { try { return fn(); } catch(e) {} } }
Output
var RESULT=50;function retry(a){for(var b=0;b<3;b++)try{return a()}catch(a){}}
Compress evaluates BASE * FACTOR = 50 at compile time, inlines MAX_RETRIES = 3 directly into the loop condition, and removes the dead DEBUG branch entirely. Constants that are only used once are inlined and their declarations removed. This demonstrates Terser's static analysis capabilities beyond simple whitespace stripping.
FairLicense comment preserved -- /*! block retained
Input
/*! * MyLib v2.1.0 | MIT License | (c) 2024 Example Corp */ // Internal helper -- will be removed function _clamp(value, min, max) { // Clamp value between min and max return Math.min(Math.max(value, min), max); }
Output
/*! * MyLib v2.1.0 | MIT License | (c) 2024 Example Corp */ function _clamp(a,b,c){return Math.min(Math.max(a,b),c)}
Terser's format option preserves comment blocks starting with /*! -- these are conventionally used for license headers that must remain in distributed files. All other comments, including internal documentation and inline remarks, are stripped. Use this pattern to stay legally compliant while still achieving maximum compression on the rest of your library.
FAQ

Frequently Asked Questions about JavaScript Minification

Common questions from developers about JS minifiers, Terser, and file size optimization
What is a JavaScript minifier and how does it work?
A JavaScript minifier is a tool that reduces the file size of JS code by removing comments, whitespace, newlines, and unnecessary characters without changing the code's behavior. Advanced minifiers like Terser also perform variable mangling (renaming local variables to single characters), dead code elimination (removing unreachable branches), and constant folding (evaluating static expressions at compile time). The result is semantically identical code that loads and executes faster in the browser, directly improving page speed metrics like Time to Interactive and Largest Contentful Paint.
Is this JavaScript minifier free to use?
Yes, this online JS minifier is completely free to use with no signup, no rate limits, and no watermarks. It runs Terser entirely in your browser via a CDN-hosted script, so your JavaScript code never leaves your machine. There is no server processing your code -- everything happens client-side in real time. You can minify as many files as you need, as often as you need, at no cost.
What is Terser and why is it better than other JS minifiers?
Terser is the industry-standard JavaScript minifier and the successor to UglifyJS. It is used internally by webpack, Vite, Rollup, Parcel, and esbuild. Unlike regex-based minifiers, Terser parses your JavaScript into an Abstract Syntax Tree (AST), which allows it to correctly handle all edge cases including strings with operator characters, regex literals, template literals, and complex destructuring. It supports all modern JavaScript syntax including ES2020+, optional chaining, nullish coalescing, and class fields -- making it suitable for any modern codebase.
What does variable mangling do to my JavaScript?
Variable mangling renames local variables and function parameters from their original descriptive names to short single-character or two-character names like a, b, c. For example, var userAccountBalance becomes var a. This reduces the total character count of your code significantly beyond what whitespace removal alone achieves. Local mangling only affects variables scoped within functions, so it is safe for all code. Top-level (global) mangling also renames module-level variables, which is ideal for bundled scripts but should be avoided for libraries that expose a public API by name.
What does the Compress option do in the JS minifier?
The Compress option runs Terser's full optimization pass, which includes several advanced transformations: dead code elimination removes branches and statements that can never be executed; constant folding evaluates expressions like 2 * 3 at compile time and replaces them with 6; unreachable code after return or throw statements is pruned; and multiple optimization passes ensure the output is as compact as possible. Compression is safe for all valid JavaScript and is recommended for production builds. It has no side effects on semantically correct code.
Should I enable the Drop console option?
Enabling Drop console removes all calls to console.log(), console.warn(), console.error(), console.info(), and related methods from your minified output. This is highly recommended for production builds where debug output is unnecessary and could expose internal logic to end users. However, you should only enable this option if you are certain no user-facing messages are delivered via console methods. If your application uses console output as part of its intended functionality -- for example, in a developer-facing SDK -- leave this option disabled.
How much file size reduction can I expect from JS minification?
The amount of size reduction depends on how heavily commented and formatted your original code is, and which options you enable. Whitespace and comment removal alone typically reduces file size by 20 to 40 percent. Adding variable mangling can bring total savings to 40 to 60 percent. Enabling compression (dead code elimination, constant folding) can push savings higher still. Real-world production bundles commonly achieve 50 to 70 percent reduction with all options enabled, which translates directly to faster load times, lower bandwidth costs, and improved Core Web Vitals scores.
Is my JavaScript code safe when using this tool?
Your JavaScript code is completely safe. Terser runs entirely in your browser as a client-side script loaded from jsDelivr CDN. No code is transmitted to any server, logged, stored, or analyzed. The minification process happens locally in your browser's JavaScript engine. You can verify this by opening your browser's network inspector while using the tool -- you will see no outgoing requests containing your code. This makes the tool safe for proprietary, commercial, and sensitive codebases.
Can I minify JavaScript for React, Vue, or Angular projects with this tool?
This tool is ideal for minifying plain JavaScript files or ES module snippets. For full React, Vue, or Angular project builds, your build tool (webpack, Vite, or Angular CLI) already invokes Terser automatically in production mode with equivalent or more advanced configuration. Use this online minifier when you need to quickly check the compressed size of a specific function or module, audit what Terser does to a particular code pattern, or minify standalone scripts that are not part of a build pipeline. For batch minification of entire projects, integrate Terser via npm in your CI/CD pipeline.
What is the difference between JS minification and JS obfuscation?
Minification reduces file size while keeping the code semantically identical and still readable (though less so) by a knowledgeable developer. The primary goal is performance -- faster downloads and parsing. Obfuscation, by contrast, deliberately transforms code to make it difficult for humans to understand, using techniques like string encoding, control flow flattening, and dead code injection. Obfuscation typically increases file size and has a performance cost. For production web apps, minification is universally recommended. Obfuscation is a separate concern for code protection and is not something Terser provides.

Need a disposable email? Generate a free, instant throwaway address -- zero signup, zero trace, works immediately.

Get Free Temp Mail ->