JavaScript Minifier
Compress your JavaScript code instantly — remove comments, strip console.log statements, shorten booleans, and reduce file size by up to 60%. Free, fast, and 100% browser-based — your code never leaves your machine.
How to Use the JS Minifier
- Paste your JavaScript — Copy your JS source code and paste it into the
input area above. You can also upload a
.jsfile or drag & drop it directly. - Choose a preset — Select Safe for zero-risk minification, Aggressive for the best balance (recommended), or Maximum to enable all optimizations. Or click "Advanced Options" to control each setting individually.
- Click "Minify JS" — The tool instantly processes your code and shows the minified result with before/after size comparison and a breakdown of what was removed.
- Copy or Download — Click "Copy" to copy the minified JS to your
clipboard, or "Download .js" to save it as
script.min.jsfor deployment.
Beautify mode: Switch to the Beautify tab to format minified or poorly-indented JavaScript into clean, readable code with your preferred indentation.
About Our Free JavaScript Minifier
JavaScript is the most resource-intensive asset on most websites. Every JS file must be downloaded, parsed, compiled, and executed before your page becomes interactive — a process that directly impacts Time to Interactive (TTI), First Input Delay (FID), and Interaction to Next Paint (INP). Minifying your JavaScript is one of the simplest and most effective ways to improve all three metrics.
Our JS Minifier is a best-in-class, free online tool that offers 10 granular optimization options — far more control than any other online JavaScript minifier:
- Comment removal — Strips both
//single-line and/* */multi-line comments, with an option to preserve/*! */license headers - Whitespace collapsing — Removes excess spaces, tabs, blank lines, and unnecessary whitespace around brackets, semicolons, and commas while preserving syntax-required spaces after keywords
- console.* removal — Strips
console.log,.warn,.debug,.info,.error,.trace,.dir,.table, and more — with safe nested-parenthesis matching so complex arguments never break - debugger removal — Removes
debugger;breakpoints that should never ship to production - Boolean shortening — Converts
trueto!0andfalseto!1, saving 2-3 bytes per occurrence - undefined simplification — Replaces
undefinedwithvoid 0, which is shorter and immune to variable shadowing - Trailing semicolons — Removes the last
;before}, safe per the ECMAScript specification - Empty statement cleanup — Collapses
;;runs and removes standalone empty statements
100% browser-based — your code is never uploaded to any server. All processing runs entirely in your browser using JavaScript. No file size limits, no signup, no privacy concerns. Unlike many competitor tools that send your code to a server for processing, your proprietary source code stays completely private.
Our tokenizer fully supports ES6+ syntax including arrow functions, template literals with nested expressions, destructuring, classes, async/await, and optional chaining. String literals, regex patterns, and template literals are automatically protected throughout the entire minification pipeline — they are never modified.
Why Choose Our JS Minifier Over Others?
- console.log removal — Most online JS minifiers don't offer this at all.
Our tool safely removes all
console.*calls with proper nested-parenthesis matching, soconsole.log(foo(bar, baz))is removed completely without breaking the surrounding code. - ES6+ template literal protection — Template literals like
`Hello ${name + `!`}`with nested expressions and even nested templates are fully protected. Many basic minifiers corrupt these. - Regex literal detection — Our tokenizer correctly distinguishes
/regex/gfrom divisiona / busing context analysis. This prevents the common failure mode where regex patterns get corrupted. - 10 individual options + 3 presets — Unlike competitors that offer all-or-nothing minification, you control exactly what gets removed. Need to keep comments but remove console.log? Want booleans shortened but not undefined? Full granular control.
- "What was removed" audit — After every minification, see exactly how many comments, console calls, debugger statements, and booleans were processed. Not just a percentage — a full breakdown.
- Built-in Beautifier — Toggle to Beautify mode to format any minified JavaScript with your preferred indent style (2 spaces, 4 spaces, or tabs). Most competitors offer this as a separate tool.
- Draft persistence — Your last input is saved in localStorage and restored automatically when you return. Never lose work-in-progress.
When Should You Minify JavaScript?
- Before deploying to production — Always serve minified JS on live sites. JavaScript is parser-blocking and render-blocking — every byte saved directly reduces Time to Interactive and improves user experience.
- Optimizing WordPress sites — WordPress themes and plugins often include verbose, heavily-commented JavaScript. Minifying can reduce file sizes by 30-50%. Use WP Rocket or Autoptimize for automatic minification, or this tool for individual files.
- Cleaning up for production — Remove
console.loganddebuggerstatements that should never reach end users. These slow down rendering, can leak internal data, and look unprofessional in the browser console. - Static sites without a build tool — If you're not using webpack, Vite,
or Parcel, this tool gives you production-grade minification in one click. Paste your
script, download the
.min.jsfile, and deploy. - Improving Lighthouse scores — If your PageSpeed report flags "Reduce unused JavaScript" or "Minify JavaScript", this tool is the fastest fix. Combine with GZIP on your server for maximum impact.
- Third-party script optimization — Vendor scripts often include development comments and formatting. Minify them before embedding to reduce your page weight.
Pro tip: For best results, combine JS minification with GZIP/Brotli compression on your server, async/defer loading for non-critical scripts, and code splitting to load only what each page needs.
Frequently Asked Questions
What is JavaScript minification?
Will minifying JavaScript break my code?
How much file size can I save?
Is it safe to remove console.log in production?
console.log with large objects), can leak sensitive
information (API keys, user data, internal state), and serve no purpose for end users.
Our tool safely matches the full console.*() call including nested
parentheses, so complex arguments like console.log(foo(bar, baz)) are
removed completely without affecting surrounding code.
What's the difference between minification and obfuscation?
Does minifying JavaScript help SEO?
Does this tool support ES6+ and modern JavaScript?
=>), template literals with nested ${} expressions,
destructuring, classes, async/await, optional chaining (?.),
nullish coalescing (??), and more. String literals and template literals
are automatically protected and never corrupted.