100% Client-Side • Powered by Terser AST Parser • Zero Cloud Upload

Free JavaScript (JS) Minifier & Optimizer

Minify, compress, and beautify JavaScript code in your browser. Eliminates whitespace, dead code, and comments while safely preserving strings, regex, and modern ES6+ syntax.

Terser AST Parser ES6+ & Async/Await Ready Beautify / Formatter Ctrl + Enter Shortcut
Format Indent:
1
1
Original JS Size 0 B 0 lines
Minified Output 0 B 0 lines
Bandwidth Savings 0 B 0% reduction
Terser AST Time 0 ms 100% In-Browser

How to Minify & Optimize JavaScript Online

Compress your script bundles and boost web performance in three easy steps.

1

Paste or Upload JS Code

Copy your JavaScript code into the editor or upload an existing .js file using the Upload button.

2

Click Minify or Beautify

Press Minify JavaScript to parse and compress with Terser, or click Beautify to neatly format and indent code.

3

Copy or Download

Click Copy to transfer code directly to your clipboard or Download to save a production-ready script.min.js file.

Real-World JavaScript Minification Example
Original Development JavaScript (198 Bytes)
// Calculate discount price function calculateDiscount(originalPrice, discountRate = 0.15) { const savings = originalPrice * discountRate; const finalPrice = originalPrice - savings; return finalPrice; }
Optimized Minified JavaScript (89 Bytes, -55.1% Saved)
function calculateDiscount(originalPrice,discountRate=.15){return originalPrice-originalPrice*discountRate}

Why Parser-Based Minification (Terser) Matters

  • Safe Abstract Syntax Tree (AST) Parsing: Unlike naive regex cleaners that corrupt regex literals or template strings, Terser understands JavaScript grammar.
  • Safe Dead Code Elimination: Detects unreachable branches, unreferenced variables, and folds constant expressions safely.
  • Zero Security Risks: Your code is analyzed as data structure tokens; it is never evaluated or executed.
  • Preserves Modern ES6+ Syntax: Handles arrow functions, async/await, optional chaining (?.), classes, and object destructuring.

Common JS Minification Pitfalls to Avoid

  • Aggressive Variable Mangling: Renaming top-level variables can break HTML inline event handlers (e.g. onclick="submitForm()"). We keep mangling off by default.
  • Stripping License Comments: Open-source licenses (MIT, Apache) require attribution. Our tool preserves /*! ... */ blocks automatically.
  • Syntax Errors Before Minifying: Unclosed brackets or missing commas prevent compilation. Terser reports the exact line and column of any syntax issue.
  • Breaking Template Literals: Naive whitespace removers collapse spaces inside backticks; Terser protects template strings verbatim.

Frequently Asked Questions

Learn more about JavaScript minification, Terser options, and web performance.

What is JavaScript Minification and why is it important?
JavaScript minification is the process of removing all unnecessary characters from code—such as whitespace, newlines, comments, and dead code—without altering its functionality. It significantly shrinks file sizes, speeds up page load times, reduces bandwidth consumption, and improves Google Core Web Vitals (such as INP and FCP).
How does Terser minify code differently than simple text tools?
Terser is the industry-standard JavaScript minifier used by webpack, Vite, and Rollup. It converts code into an Abstract Syntax Tree (AST), ensuring that variables, regular expressions, strings, and template literals are analyzed mathematically. Simple regex tools often break code by removing spaces inside quotes or corrupting complex logic.
What does "Mangle Variable Names" mean and is it safe?
Mangling shortens local variable and parameter names to single letters (such as calculateTotal to a) to save maximum bytes. While safe for internal functions, mangling top-level variables can break code if external scripts or HTML inline handlers call those functions by name. For this reason, mangling is disabled by default in our tool.
Is my JavaScript code uploaded to your servers or executed?
No! All processing is executed 100% locally in your web browser using our bundled client-side Terser engine. Your code is never executed, never evaluated, and never sent across the internet to any server. Your proprietary logic remains completely private.
Does this tool support modern ES6+, async/await, and classes?
Yes! Our Terser integration supports modern ECMAScript standards (ES2022+), including arrow functions, async/await, classes, optional chaining (?.), nullish coalescing (??), and object spread syntax.