Use JavaScript Minifier

Enter your data below to use the JavaScript Minifier

📌 Try these examples:
RESULT

Last updated

Example: Variable Name Mangling

// Before (with descriptive names, 312 bytes):
function calculateCompoundInterest(principal, annualRate, compoundFrequency, years) {
  const ratePerPeriod = annualRate / compoundFrequency;
  const totalPeriods = compoundFrequency * years;
  const finalAmount = principal * Math.pow(1 + ratePerPeriod, totalPeriods);
  return finalAmount - principal;
}

// After (mangled, 118 bytes — 62% reduction):
function calculateCompoundInterest(a,b,c,d){const e=b/c,f=c*d;return a*Math.pow(1+e,f)-a}

Example: Comment Stripping

// Before (with comments, 520 bytes):
/**
 * Debounce function - delays execution until after wait ms
 * have elapsed since the last invocation.
 * @param {Function} func - Function to debounce
 * @param {number} wait - Milliseconds to wait
 */
function debounce(func, wait) {
  let timeout; // Store the timeout ID
  
  return function executedFunction(...args) {
    // Clear any existing timeout
    clearTimeout(timeout);
    
    // Set a new timeout
    timeout = setTimeout(() => {
      func.apply(this, args); // Execute the function
    }, wait);
  };
}

// After (minified, 121 bytes — 77% reduction):
function debounce(func,wait){let timeout;return function(...args){clearTimeout(timeout);timeout=setTimeout(()=>{func.apply(this,args)},wait)}}

Example: License Comment Preservation

// Before:
/*!
 * jQuery v3.7.1 | (c) OpenJS Foundation and other contributors
 * Released under the MIT license
 */

// Internal helper - will be removed
function _internal() { /* ... */ }

// Public API
function publicMethod(x) {
  return x * 2;
}

// After (license preserved, other comments removed):
/*!
 * jQuery v3.7.1 | (c) OpenJS Foundation and other contributors
 * Released under the MIT license
 */
function _internal(){}function publicMethod(x){return x*2}

Example: Dead Code Elimination

// Before:
const DEBUG = false;

function processData(data) {
  if (DEBUG) {
    console.log('Processing:', data);  // never runs
    console.log('Stack:', new Error().stack);  // never runs
  }
  
  return data.map(item => item.value);
  
  // Unreachable code:
  console.log('Done');
}

// After (dead code removed):
function processData(a){return a.map(b=>b.value)}

Compression Statistics

File: application.js

Original:          248,320 bytes  (242 KB)
Whitespace only:   181,450 bytes  (177 KB)  — 27% reduction
+ Comments:        168,200 bytes  (164 KB)  — 32% reduction
+ Mangling:        144,800 bytes  (141 KB)  — 42% reduction
+ Dead code:       139,600 bytes  (136 KB)  — 44% reduction
Final minified:    139,600 bytes  (136 KB)  — 44% reduction

Gzip estimate:      42,800 bytes   (42 KB)  — 83% reduction
Brotli estimate:    36,500 bytes   (36 KB)  — 85% reduction

Source Map Output

// Minified file (app.min.js):
function isPrime(n){if(n<2)return!1;for(let i=2;i<=Math.sqrt(n);i++)if(n%i===0)return!1;return!0}
//# sourceMappingURL=app.min.js.map

// Source map allows browser DevTools to show original:
// app.min.js.map:
{
  "version": 3,
  "file": "app.min.js",
  "sources": ["app.js"],
  "sourcesContent": ["function isPrime(n) {\n  if (n < 2)..."],
  "mappings": "AAAA,SAASA,QAAQC,GAAG..."
}

Batch Minification Results

Processing 6 files...

File                  Original    Minified    Gzip      Savings
main.js               242 KB      136 KB      42 KB     44%
vendor.react.js       820 KB      412 KB      128 KB    50%
vendor.lodash.js       71 KB       25 KB        9 KB    65%
utils.js               45 KB       18 KB        6 KB    60%
router.js              28 KB       11 KB        4 KB    61%
styles-in-js.js        62 KB       31 KB       10 KB    50%

Total                1,268 KB     633 KB      199 KB    50%

Minification Options Reference

Paste your JavaScript code to minify it instantly. The minifier preserves all functionality while achieving the maximum possible size reduction.

Example: Basic Minification

// Before (formatted, 198 bytes):
function isPrime(n) {
  if (n < 2) return false;
  for (let i = 2; i <= Math.sqrt(n); i++) {
    if (n % i === 0) return false;
  }
  return true;
}

// After (minified, 72 bytes — 64% reduction):
function isPrime(n){if(n<2)return false;for(let i=2;i<=Math.sqrt(n);i++)if(n%i===0)return false;return true}

Example: ES6+ to ES5 Transpile + Minify

// Before (ES6+):
const multiply = (a, b = 1) => a * b;
const [first, ...rest] = [1, 2, 3, 4, 5];
const obj = { x: 1, y: 2 };
const { x, y } = obj;

// After (transpiled to ES5 + minified):
var multiply=function(a,b){return b===void 0&&(b=1),a*b};var _ref=[1,2,3,4,5],first=_ref[0],rest=_ref.slice(1);var obj={x:1,y:2},x=obj.x,y=obj.y;

Frequently Asked Questions

Simply enter your data, click the process button, and get instant results. All processing happens in your browser for maximum privacy and security.

Yes! JavaScript Minifier is completely free to use with no registration required. All processing is done client-side in your browser.

Absolutely! All processing happens locally in your browser. Your data never leaves your device, ensuring complete privacy and security.