About the JavaScript Minifier
The JavaScript Minifier uses Terser, the industry-standard JavaScript compressor used by build tools like Webpack and Vite, running entirely in your browser. It removes whitespace and comments, shortens local variable and function names, removes dead code and applies dozens of safe optimizations.
Minified scripts are often 50–70% smaller, so they download faster, especially on mobile networks. This helps page speed scores and user experience. The tool supports modern ES2015+ syntax and reports syntax errors with line and column numbers, which also makes it a quick way to validate your code.
What Terser does to your code, step by step
Take this small function:
// Add tax to a price
function addTax(price, rate) {
const tax = price * rate;
return price + tax;
}
console.log(addTax(100, 0.17));
The minified output is a single line where the comment is gone, the local names are shortened and the temporary variable is removed:
function addTax(a,d){return a+a*d}console.log(addTax(100,.17));
Notice that the function name addTax stays the same, because other code may call it. Only names that are private to the function are renamed, which is why minification is safe.
Mistakes to avoid
- Do not minify code that relies on function names at runtime (for example, code that reads
fn.name). Test after minifying. - Keep the readable source. You cannot get your original variable names back from a minified file.
- Read the error message. If the tool reports a syntax error with a line and column, the code would also fail in the browser. Fix it before publishing.
How to use the JavaScript Minifier
- Paste your JavaScript into the input box.
- Choose whether to shorten variable names.
- Click Minify JavaScript.
- Copy the minified code and check the size reduction.
Frequently asked questions
Will minification break my code?
Terser applies only safe transformations. Code that relies on function names at runtime may need the Shorten variable names option turned off.
Does it support ES6 and newer syntax?
Yes. Modern syntax such as arrow functions, classes, async/await and modules is fully supported.
Is my code uploaded?
No. Terser runs inside your browser, so your source code never leaves your device.
