JavaScript Minifier - Compress JS Online with Terser
JavaScript Minifier
Compress and mangle JavaScript, and see exactly how much you save
Terser Engine
Uses Terser, the minifier behind most modern build tools, supporting current JavaScript syntax including classes, async code and modules.
Options That Matter
Choose compression, name mangling, ES module mode, console removal and how comments are handled.
Syntax Errors with Position
If the code cannot be parsed you see the line and column, so you can fix it before minifying.
Private
Your code is minified in your browser and never uploaded, which matters for unreleased or proprietary scripts.
What JavaScript Minification Does
A minifier rewrites JavaScript so it behaves the same but is much smaller. It removes comments and whitespace, shortens local variable and function names (mangling), and simplifies expressions and removes code that can never run (compression). Smaller scripts download and parse faster, which helps load times and Core Web Vitals.
Be careful with the top-level option. Mangling names at the top level of a classic script renames globals, which breaks code that is called from HTML attributes such as onclick or from other scripts. It is safe for self-contained scripts and ES modules. Removing console calls can also drop expressions with side effects inside the call. Always test the minified file before you deploy it.
Key Takeaways
- Behavior stays the same: Minification changes the text of the code, not what it does, unless you opt into removing console calls or top-level names.
- Source maps are not produced: For production debugging use a build tool that emits source maps. This tool is for quick, one-off minification.
- Related tools: Use the JavaScript Beautifier to make minified code readable again.