Minify JavaScript files in your browser

Strip comments, join statements with ASI-safe semicolons, and optionally uglify names. Licence banners stay; the file never leaves this tab.

JS
No JS selected
Drop a file to start
Drop JS files here

or browse your device. Everything is processed on this device

No JS to hand?

Got it on your clipboard?

How to minify JavaScript

01
Drop the JavaScript

Choose a .js file or paste the source. It stays in this tab and is never sent to a server.

02
Choose comments, minify and uglify

Comments are stripped and statements joined by default. Turn Minify off if you only want indentation and comments touched. Turn Uglify on when you want Terser to rename locals.

03
Check the preview

The after tab is the file you will download. Minify keeps names; Uglify rewrites them. Licence banners beginning with /*! survive both.

04
Copy or download

Put the minified source back in the project. Already-minified bundles come back unchanged rather than being made larger.

Minify versus uglify

Minify is a scanner: it drops comments and punctuation spacing, then joins lines by inserting a semicolon wherever automatic semicolon insertion would have. It never renames a binding, folds an expression or removes unreachable code. A newline is kept after a closing brace when the next token is (, [ or a backtick, because a scanner cannot tell a function declaration from a call.

Uglify is Terser, fetched the first time you turn it on. That is a real parser: it mangles names, compresses the grammar and can change behaviour if the source relied on Function.prototype.toString or similar. Use it when you want a build-tool result in the browser, not when you still need to read the file.

For a hand-written script Minify is usually enough. A production bundle that has already passed through a build tool will barely move either way, and that is the honest result. In either case, serve JavaScript with gzip or brotli as well, because transport compression is the much larger saving.

JavaScript minification FAQ

Is this a full JavaScript minifier?

Minify is whitespace, comments and ASI-safe line joining, with names left alone. Turn Uglify on to parse the file with Terser, rename variables, shorten property access where it is safe and remove dead code. Terser is downloaded only for that pass, not for HTML, CSS or JSON.

Why are some line breaks still there after Minify?

A closing brace followed by (, [ or a backtick keeps its newline. Those are the cases where joining would turn a function declaration plus a later call into an immediately invoked function, and a scanner cannot tell the two apart. Everywhere else, lines are joined and a semicolon is inserted where ASI would have inserted one.

What does Minify actually remove?

Comments, spaces around punctuation and operators, and line breaks that are not needed for ASI. return 1, else if and a + +b keep the space they need. Strings, templates and regular expressions are left exactly as written.

Does Uglify rename my variables?

Yes. Locals are mangled the way Terser would in a build. Globals, exported names and properties that cannot be proved local stay. Turn it off when the source still has to be readable or when code inspects function source.

Are strings, templates and regular expressions safe?

They are scanned as opaque literals under Minify, so // inside a URL, /* inside a string, whitespace in a template and slashes inside a regular expression are not treated as comments. Uglify parses the file properly. The file itself is never executed.

What happens to licence comments?

A block comment beginning with /*! is kept even when Strip comments is on, including under Uglify. Other comments remain when you switch stripping off. This does not try to decide whether an unmarked comment contains legal terms.

Will this make a bundled script smaller?

Usually not by much. Bundlers normally run a real minifier already, leaving little for Minify or Uglify to do. If this pass cannot beat the input size, the original file is returned unchanged.

Drop more files

Same format joins the queue. Anything else re-routes to its own tool.