Online JavaScript Minifier

Paste your JavaScript or drop your files in, and get the Terser-minified version straight away. See the size before and after, the saving and the gzipped result. Your code never leaves your browser.

JavaScript code

Drop .js files here, or . Drop several files and they are combined in order and minified as one.

Minification options

The defaults are chosen so that your code keeps behaving the same way. The last two boxes below do change observable behaviour when you tick them.

How do you minify JavaScript?

  1. Paste the code or drop the files in

    Paste your JavaScript into the box, or drag .js files onto it. Drop more than one and they are joined with a semicolon between each pair.

  2. Set the options

    Removing comments, turning off name shortening or dropping console calls is up to you. The defaults are set so your code keeps behaving the same way.

  3. See what you saved

    The size before and after, the saving and the gzipped output sit side by side. If the code cannot be parsed, it tells you the line and column where it stopped.

  4. Copy or download

    Put the minified code on your clipboard with one click, or download it straight as a .min.js file. At no point does your code go to a server.

What does minification actually remove?

Minification is not about making code unreadable; it is about dropping every character the browser does not care about. Indentation, line breaks, comments and optional semicolons do nothing at runtime — they only add bytes to the download. The table below shows which transformations the default settings apply.

Transformation Before After
Whitespace and indentation if (a) { b(); } if(a)b();
Comments // find the sum topla(); topla();
Local variable names function f(){var toplamTutar=1;return toplamTutar} function f(){return 1}
Constant expressions var ms = 60 * 60 * 1000; var ms=36e5;
Unreachable code if (false) { eskiYol(); } (dropped entirely)
Unnecessary braces for (;;) { x(); } for(;;)x();

Why Terser?

This tool is not a script that hacks at your code with regular expressions: it is Terser itself, the library bundlers like webpack, Rollup and Vite use to build their production output. Terser parses the code into a real syntax tree, resolves its scopes and prints the tree back out. That is why it never mistakes a slash inside a string for the start of a comment, or a regular expression literal for a division.

The minifier is not downloaded when the page opens. It loads the first time you press Minify, so someone who only skims the page never pays for that file.

Running your own test suite against the output once before shipping is always a good habit. The settings this tool uses were chosen by measurement, not assumption: across dozens of cases — automatic semicolon insertion, regular expression literals, template strings, generators, async/await, classes and private fields — the minified code produced exactly the same result as the original.

The traps that break code silently

Tools that minify with a home-grown “strip the whitespace” script always break in the same places. None of these raises a syntax error: the code still runs, it just runs wrongly.

Trap Why it breaks In this tool
Automatic semicolon insertion A return at the end of a line returns undefined, not the line beneath it. A tool that blindly joins lines reverses that behaviour. Rewritten from the syntax tree, so the meaning is preserved.
Slash: division or regular expression? a = b / c and a = /re/g use the same character. Only the grammatical context tells them apart. Decided by the parser, never guessed.
A function losing its name Drop a nested function’s name and fn.name becomes an empty string; dependency containers and name-based dispatch collapse without a word. Names are kept by default; turning that off is an explicit choice.
Files glued end to end If a file that does not end in a semicolon is followed by one starting with a parenthesis, the two are read as a single call expression. A semicolon is placed after every file when they are combined.

Minify, uglify, compress and gzip are not the same thing

Term What it does Where it happens
Minify Drops needless characters and shortens names. The result is still valid JavaScript. At build time, once.
Uglify The old name for the same job. UglifyJS never fully supported modern syntax, so Terser took its place. A thing of the past.
Obfuscate Deliberately makes code unreadable: encodes strings, flattens control flow. Usually makes files bigger. A different tool for a different purpose.
Gzip / Brotli Compresses bytes for transfer. The browser unpacks them; the file on disk is no smaller. On every request, at the server.

They do not replace each other, they work together. Because minification shortens repeated names, it gives gzip more patterns to find: a file that is minified and then gzipped is visibly smaller than one that is only gzipped. The result panel above shows the minified size and the gzipped size of that output side by side.

Key features

A real parser

Your code is parsed into a syntax tree and printed back out by Terser, the minifier production bundlers use — not chopped up with regular expressions.

Before, after and gzip

Shows how many bytes you started with, how many you end with, the saving, and the gzipped size of the output.

Points at the line that failed

If the code cannot be parsed it tells you the line and column where it stopped, instead of quietly handing you half an output.

Combine several files

Drop several .js files and they are joined with a semicolon between each pair, then minified as one file.

Adjustable aggressiveness

Keep comments, turn name shortening off, drop console calls. The options that change behaviour are marked as such.

Nothing reaches a server

Minification runs in your browser. Your code never reaches us and is never stored, so you can paste a closed-source file without a second thought.

FAQ

Minification shrinks a file without changing what it does. Indentation, line breaks, comments and optional semicolons are dropped, local variable names are shortened to a letter or two, and constant expressions are folded. The result is still valid JavaScript that a browser runs with no extra step.

No. Minification runs entirely in your browser; the code you paste or drop never reaches us and is never stored anywhere. You can safely use it on closed-source files.

Terser — the same library webpack, Rollup and Vite use to build production bundles, running as its browser build. Your code is not chopped up with regular expressions: it is parsed into a real syntax tree, its scopes are resolved, and the tree is printed back out.

With the default settings, yes. The defaults are chosen to preserve behaviour: top-level names survive, function and class names are kept, and console and debugger statements are only removed if you ask. Even so, running your own test suite against the output once before shipping is a good habit.

Yes. Terser reads modern syntax in full: arrow functions, template literals, classes and private fields, generators, async/await, optional chaining, nullish coalescing, BigInt and numeric separators. If the file starts with import or export it is parsed as a module.

Yes, drop as many .js files as you like. They are concatenated in the order you dropped them, with a semicolon between each pair. That detail matters: if a file that does not end in a semicolon is followed by one starting with a parenthesis, a plain concatenation reads them as a single call expression and breaks.

Only if your code never reads function names. With the box unchecked, nested function names are dropped and fn.name becomes an empty string. Dependency containers, name-based dispatch and logging that reads an error class’s name all break silently. The few hundred bytes it saves are rarely worth the risk.

Servers send JavaScript compressed, and that is the number of bytes a visitor actually downloads. The tool measures it by running the minified output through the browser’s own gzip encoder rather than estimating. Minifying first also helps gzip: shortened, repeated names give it more patterns to work with, so minify plus gzip beats gzip alone by a visible margin.

The tool never emits half-minified or broken output. The parser reports where it stopped, with a line and column number, and the result panel stays closed. That makes the minifier a quick syntax check as well.

Minification aims at size; unreadability is a side effect and a source map undoes it. Obfuscation aims at unreadability on purpose: it encodes strings, flattens control flow and adds decoy branches. It usually makes files bigger and slower. They are different jobs, and this tool does minification.

No, this tool only goes one way. Minification is not encryption, but the information it removes — comments, original variable names, formatting — cannot be recovered; a beautifier only re-adds readable indentation. To get back to the original source you need a source map generated at build time.

Easily get your dream job!

Sign Up
Sign up Easily
Show your programming skills
Evaluate the offers