JavaScript Minifier Optimize your JS code

Highly configurable JavaScript compressor for smaller file sizes

Input JavaScript
  • Parse Options
  • Support top-level return statements
  • Support HTML comments () in JavaScript
  • Support #!command as the first line
  • Compress Options
  • Enable all compression options
  • Turn booleans into 0 and 1
  • Collapse single-use var/let/const variables
  • Set default values for options that can't be configured here
  • Remove unused directive prologs
  • Force ES5 compliance (disables ES6+ optimizations)
  • Parse as single expression (e.g., JSON)
  • Assume these globals are defined (comma-separated)
  • Hoist export statements to facilitate other optimizations
  • Optimizations for if/return and if/continue
  • Inline simple functions
  • Prevent discarding unused function arguments
  • Prevent discarding or mangling function names
  • Prevent compression of Infinity to 1/0
  • Optimizations for do, while and for loops
  • Negate imported booleans
  • Number of optimization passes (default: 1)
  • Rewrite property access using dot notation
  • List of functions that produce no side effects (comma-separated)
  • Assume getters have no side effects
  • Allow function optimizations that might be unsafe
  • Improve optimization on variables assigned with and used as constant values
  • Join consecutive simple statements
  • Assume functions and vars have no side effects
  • Enable top level variable and function name mangling and unused property removal
  • Apply potentially unsafe optimizations
  • Optimize numerical expressions like 2 * x * 3 into 6 * x
  • Optimize numerical expressions like Math.pow(x, 3) into x*x*x
  • Assume built-in symbols like Symbol.iterator are not overwritten
  • Assume methods like Array.prototype.slice don't throw
  • Optimize expressions like Array.prototype.slice.call(a) into [].slice.call(a)
  • Assume regular expressions are constant
  • Assume undefined is not redefined
  • Drop unused variables/functions
  • Mangle Options
  • Enable name mangling (shortening variable names)
  • Don't mangle class names
  • Don't mangle function names
  • List of names to exclude from mangling (comma-separated)
  • Mangle names declared in the top level scope
  • Format Options
  • Format the output in a readable way
  • Preserve certain comments in output
  • Number of spaces for indentation (when beautifying)
  • Maximum line length (when beautifying)
  • Prepend this string to the output
  • Preferred quote style for strings
  • Add semicolons at the ends of statements
  • Preserve #!command at start of file
  • Work around WebKit bugs
  • Wrap function arguments in parentheses when needed
Select: All, None, Reset
Minified JavaScript

  About JavaScript Minification

  Why Minify JavaScript?

JavaScript minification is the process of removing all unnecessary characters from JavaScript source code without changing its functionality. This includes:

  • Removing whitespace, comments, and line breaks
  • Shortening variable and function names
  • Optimizing code structures
  • Removing dead code

The primary goal is to reduce the file size, which leads to faster page load times and reduced bandwidth usage.

  Benefits of Minification

Minifying your JavaScript offers several advantages:

  • **Faster Page Load Times:** Smaller file sizes mean browsers download and parse scripts quicker.
  • **Reduced Bandwidth Usage:** Less data transferred, which is beneficial for both servers and users.
  • **Improved SEO:** Search engines consider page speed as a ranking factor.
  • **Better User Experience:** Visitors are less likely to leave a fast-loading site.
  • **Mild Obfuscation:** Minification makes code harder to read, providing basic protection.

Tip: For production, combine minification with GZIP compression for maximum file size reduction.

  How to Use This Tool

  1. Paste your JavaScript code into the "Input JavaScript" text area.
  2. (Optional) **Adjust minification options** under "Advanced Options" to fine-tune the process.
  3. Click the **"Minify JavaScript"** button.
  4. Your minified code will appear in the "Minified JavaScript" area, along with **size statistics**.
  5. **Copy** the minified code to your clipboard or **download** it as a .js file.
  6. **Test thoroughly** after minification to ensure your code functions as expected.

Warning: Be cautious with "unsafe" options as they might change code behavior in edge cases. Always test minified output.

  Frequently Asked Questions

Q: Is my code sent to your servers?
A: No! All processing happens locally in your browser using Terser. Your code never leaves your device.

Q: Will minification break my JavaScript?
A: Generally, no. Standard minification should not break your code. However, if you enable certain "unsafe" options, or if your original code has errors, issues might arise. Always test the minified output.

Q: Can I reverse minified JavaScript?
A: Minification is a destructive process in terms of readability. While the functionality remains, restoring the original formatting (indentation, comments, variable names) is not possible. For development, keep a well-formatted version of your source code.

Q: What's the difference between minification and obfuscation?
A: Minification focuses on reducing file size while maintaining functionality. Obfuscation makes code harder to understand while also reducing size. This tool focuses on minification with some obfuscation through name mangling.

More tools

Minify HTML

Obfuscator JS