Skip to main content

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.

0 chars | 0 lines
Quick preset:

Ctrl + Enter to run

How to Use the JS Minifier

  1. Paste your JavaScript — Copy your JS source code and paste it into the input area above. You can also upload a .js file or drag & drop it directly.
  2. 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.
  3. 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.
  4. Copy or Download — Click "Copy" to copy the minified JS to your clipboard, or "Download .js" to save it as script.min.js for 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 true to !0 and false to !1, saving 2-3 bytes per occurrence
  • undefined simplification — Replaces undefined with void 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, so console.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/g from division a / b using 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.log and debugger statements 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.js file, 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?
JavaScript minification removes unnecessary characters from JS code — whitespace, comments, and line breaks — without changing how the code executes. This reduces file size, speeds up download and parse time, and directly improves Core Web Vitals scores (TTI, FID, INP) which Google uses as ranking signals.
Will minifying JavaScript break my code?
No — when done correctly. Our minifier only removes characters that have no functional impact. String literals, regex patterns, and template literals are automatically detected and protected — they are never modified. Use the Safe preset for zero-risk minification that only removes comments and whitespace. Always test minified code before deploying to production.
How much file size can I save?
Typical savings range from 20% to 60%, depending on how your code is written. Heavily commented code with verbose formatting can see 40-60% reduction. Already compact code sees 15-25%. Enabling console.log removal and boolean shortening can push savings higher. The stats panel shows your exact savings after each run.
Is it safe to remove console.log in production?
Yes — it's a best practice. Console statements slow down rendering (especially 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?
Minification reduces file size by removing unnecessary characters (comments, whitespace) while preserving the code's readability if you beautify it later. Obfuscation intentionally makes code unreadable by renaming variables to meaningless names, encoding strings, and adding dead code. Minification is for performance; obfuscation is for intellectual property protection. This tool performs minification only.
Does minifying JavaScript help SEO?
Yes — directly and measurably. Google uses Core Web Vitals as a ranking signal, and JavaScript is the most impactful asset on page performance. Minified JS downloads faster, parses faster, and executes faster — directly improving Time to Interactive (TTI), Interaction to Next Paint (INP), and First Input Delay (FID). Google PageSpeed Insights specifically flags unminified JavaScript as a performance issue.
Does this tool support ES6+ and modern JavaScript?
Yes. Our tokenizer fully handles modern JavaScript features including arrow functions (=>), 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.
How do I minify JavaScript in WordPress?
Two options: Automated (recommended): Use a caching plugin like WP Rocket, Autoptimize, or LiteSpeed Cache — all include JS minification and concatenation as toggles. Manual: Paste your theme's JS files into this tool, download the minified result, and replace the original files on your server. Keep backups of the originals for future edits.
Can I reverse or unminify JavaScript?
Partially. Our Beautify mode can restore formatting, proper indentation, and readability to minified code — making it much easier to read and debug. However, original comments and whitespace patterns are permanently lost during minification. If other tools have mangled variable names (renamed them to single letters), those cannot be restored. This is why you should always keep your original source files.
What's the difference between JS minification and GZIP?
They work at different levels and complement each other. Minification permanently removes redundant characters from the file itself. GZIP/Brotli compression is applied by the server during transmission and decompressed by the browser. For best results, do both: minify first, then enable GZIP on your server. Minified JS also compresses better with GZIP because there is less repetitive whitespace to encode.
Should I minify before or after bundling?
After bundling. Your build tool (webpack, Vite, Rollup, Parcel) should first bundle your code (resolving imports, combining files, tree-shaking unused exports), then minify the output. Most modern bundlers include minification as a built-in production step. If you're not using a bundler and have standalone JS files, minify each file individually with this tool before deploying.
Is my code safe? Is it sent to any server?
Completely safe. All processing happens 100% in your browser using client-side JavaScript. Your code is never uploaded to any server, never logged, and never stored anywhere except optionally in your own browser's localStorage as a draft (cleared with the Clear button). Close the tab and it's gone. This makes it safe for proprietary code, client projects, and sensitive business logic.

Need a Blazing-Fast, SEO-Optimized Website?

Our development team builds performance-first websites that score 90+ on Lighthouse, rank on Google, and convert visitors into customers.

Talk to an Expert