My Tool Studio
Developer

JavaScript Minifier

This JavaScript minifier runs your code through Terser, the library many bundlers use, to make it as small as practical. Terser removes whitespace and comments, shortens local names and rewrites code into shorter forms that behave the same. Options let you turn name shortening off, remove console calls and debugger statements, keep license comments, keep function and class names, treat the code as an ES module, choose ES5, ES2015 or ES2020 output and run up to three compress passes. Tick Generate source map to download a .map file with the minified code. Upload one file, or several to minify and combine into one bundle, and see the bytes saved with a gzip estimate. Your code stays in your browser.

Always freeNo sign upRuns in your browser
Output appears here...

Minify or combine several JavaScript files

Add several files, put them in order, then process them all with the options above. Files stay in your browser.

How to use

01

Paste or upload JavaScript

Put code in the Input pane or click Upload .js. Try sample loads a small function with a license comment, a debugger statement and console.log calls, so you can see what each option does.

02

Choose options and click Minify

Tick the options you need, pick Output syntax and Compress passes, and click Minify, or turn on Live mode. A syntax error shows its line and column instead of an empty result.

03

Copy or download

Click Copy, or Download to save the .min.js file, and Download .map when a source map was made. For several files, use the batch panel to download a ZIP or one combined bundle.min.js.

Why JavaScript Minifier

Terser, esbuild, UglifyJS and obfuscators compared

All of these make JavaScript harder for people to read, but they have different goals. Minifiers aim for the smallest file that still behaves the same. Obfuscators aim to hide how the code works, usually at the cost of size and speed.

This page uses Terser because it runs well in the browser and gives small output. In a project you will usually meet it, or esbuild, inside your bundler rather than on its own.

ToolWhat it doesWhere you meet it
TerserCompresses code and shortens names; forked from uglify-eswebpack's default minifier for production builds, and this page
esbuildVery fast bundler and minifier written in GoVite's default JavaScript minifier
UglifyJSThe older minifier that gave uglify its meaningOlder build setups
ObfuscatorRenames, encodes strings and adds confusing control flowCode where hiding logic matters more than size

Common questions

Does minifying JavaScript change how my code runs?
It should not. Terser only makes changes that keep normal code working the same way. Code that depends on function or class names at runtime, such as checks on fn.name, can change after mangling, so tick Keep function and class names if that applies and test the output.
What is the difference between minify, uglify and obfuscate?
Minifying shrinks code while keeping its behavior. Uglify comes from UglifyJS, an older minifier, and people often use the word to mean the same thing. Obfuscation deliberately makes code hard to understand and often makes it bigger; minified code is harder to read but not protected.
Why does JavaScript minification fail on my ES6 or TypeScript code?
Modern syntax such as arrow functions, classes, async functions and optional chaining is supported. TypeScript types, JSX and decorators are not plain JavaScript, so Terser stops with a syntax error. Compile them to JavaScript first, for example with the TypeScript compiler or esbuild.
Should I keep license comments when minifying JavaScript?
Yes, if the code includes open-source libraries whose license asks you to keep the notice. With Keep license comments ticked, comments that start with /*! or contain @license, @preserve or @copyright stay in the output. Untick it for your own code.
Can I minify a JS file without Node or a bundler?
Yes, that is what this page is for. Terser runs in your browser, so you can paste code and get the minified version without installing anything. For a project that changes often, add minification to your build instead.
How much smaller does minified JavaScript get?
It depends on the code. Long names, comments and indentation shrink the most, while code that is already compact changes less. The line under the panes shows the exact sizes and a gzip estimate for your input, and extra compress passes can save a little more.
What does Remove console.* calls do in the JS minifier?
It deletes calls such as console.log, console.warn and console.error from the output, which keeps debug messages out of production. The arguments inside those calls are dropped too, so do not put code with side effects inside a console.log.
Can I turn minified JavaScript back into readable code?
You can restore the layout with the JS Beautifier, which adds line breaks and indentation. Shortened variable names and removed comments cannot be recovered.
Does this JavaScript minifier create a source map?
Yes. Tick Generate source map and click Minify, then use Download .map. The downloaded .min.js ends with a sourceMappingURL comment that points to the map, so when you upload both files side by side, browser DevTools can show your original code in error traces.
What does the ES module option do in the JS minifier?
It tells Terser the code is an ES module, so import and export are allowed, strict mode is assumed and top-level names can be shortened because they are not global. Leave it off for a classic script whose functions other scripts on the page call by name.

More Developer tools

View all