Use the free JavaScript Minifier below: your data never leaves your browser — all work happens on your device, and nothing is uploaded to any server.
Why Minify JavaScript?
When a browser loads a page, every JavaScript file must travel over the network and then be parsed and executed. Large files slow both steps, especially on mobile connections and slower phones. Minification shrinks a file by removing what the browser does not need: comments, extra whitespace, and long variable names, while keeping the behaviour exactly the same. A file that was 100 kilobytes can become 60 or less, and across many visitors that saving adds up to real speed.
Minification is not the same as compression. Compression, like gzip, squeezes the file during transfer and the browser expands it again. Minification changes the source itself, and it combines well with compression: a minified file compresses better than the original, so using both gives the best result. The tool above minifies with Terser, the standard open-source JavaScript minifier, entirely in your browser.
How to Use the Tool
Paste JavaScript into the input box and press Minify. The output appears below, together with the sizes before and after and the percentage saved. Two options control the result. Compress removes dead code, folds constants, and shortens expressions. Mangle renames local variables to short names like “a” and “b”. Both are on by default, because together they give the smallest output.
If the output must stay readable for debugging, turn mangle off and keep compress on: the code stays structurally similar but smaller. If you need to preserve specific names, for example because other code refers to them, turn mangle off entirely. Copy the result with the Copy button, or download it as a file for your project.
What Terser Changes and What It Keeps
Terser removes comments and unnecessary whitespace, shortens variable and function names that are local to the file, and simplifies expressions it can prove equivalent, like turning “x + 0” into “x” or dropping code that can never run. It does not change the order of side effects, rename properties or global names that other files might use, or remove code it cannot prove dead. That caution is why minified output behaves like the original.
Some things need care. Code that relies on a function’s name at runtime, or that accesses properties through strings built at runtime, can break if names change. That is rare in ordinary code, but if your output misbehaves, first try turning mangle off. If the problem disappears, a name was being relied upon, and you can keep mangle off or configure it to reserve that name in your build setup.
Minification Versus Readability
Minified code is deliberately hard to read, which is fine for production but bad for debugging. The standard workflow is to keep the original source for development and ship the minified file to visitors, with a source map that lets browser developer tools show the original code while debugging. This tool is for quick jobs and learning, so it does not generate source maps; for a production build pipeline, use a bundler that does.
Never edit a minified file by hand. Always change the original and minify again, or your fix will be lost the next time the file is built, and the minified file will drift away from the source until nobody knows which one is true. Treat the minified file as a generated artefact, like a compiled program, not as source.
How Much Can You Save?
Savings depend on the code. Verbose code with long names and many comments shrinks the most, often by 40 to 60 percent. Already compact code shrinks less. Libraries with short internal names shrink less than application code with descriptive names. The percentage shown by the tool is measured on your exact input, so it is the honest number for your code, not a marketing claim.
Remember that minification is one optimisation among several. Serving files with compression, caching them with long lifetimes, splitting large bundles so visitors only download what a page needs, and removing unused code entirely all matter as much or more. Minify as part of that set, not instead of it, and measure the result on a real page, because a smaller file that still blocks rendering may need a different fix.
Limits and Safety
The tool handles standard modern JavaScript. Very new syntax may fail if the version of Terser loaded is older than the feature, and in that case the tool shows the error message instead of producing broken output. Code with syntax errors also fails with a message, which is useful: a minifier is a surprisingly good syntax checker, because it must parse the whole file before it can shrink it.
Your code never leaves your browser. It is not uploaded, stored, or seen by anyone. That makes the tool safe for snippets from private projects, though as a general habit you should still avoid pasting secrets like API keys anywhere, including into tools, because a snippet copied by accident can travel further than you intended.
