Home » Developer Tools » JavaScript Minifier
Paste JavaScript and get a smaller, faster loading version in seconds, right in your browser.
Last updated 13 November 2026
Your code never leaves your browser. Everything runs locally on your device.
Large JavaScript files slow down your pages, especially on mobile connections. The JavaScript Minifier removes comments and extra whitespace, shortens variable names, and simplifies code by removing dead code and folding constants, so your code stays working exactly as before but downloads much faster.
Everything runs in your browser, so your code is never uploaded to a server. Paste your script, minify it, and copy the result straight into your project.
A JavaScript minifier is a tool that takes readable JavaScript and rewrites it into the smallest form that still runs the same way. It strips out comments and extra whitespace, shortens local variable names to one or two letters, and simplifies the code itself. That last step is called compression, and this tool always runs it: Terser removes code that can never run, folds constants into their final values, and joins short statements together. The result is a file that looks like a wall of text to a human reader but behaves exactly like the original for the browser.
Why does that matter? A smaller file downloads faster, and JavaScript is often the slowest part of a page load. On a fast office connection the saving is barely noticeable, but on a slow mobile connection it is easy to feel. That is why production sites ship minified JavaScript even though developers write and debug the readable version. You keep the readable file for editing and publish the minified file for visitors.
This tool has two switches, plus one behaviour that is always on. Here is what each one does.
Here is a small function run through the tool with the default options, with the exact numbers:
Input, 60 characters:
function add(a, b) { return a + b; } console.log(add(2, 3));
Output, 51 characters:
function add(d,n){return d+n}console.log(add(2,3));
The output is 9 characters shorter than the input. 9 divided by 60 is 0.15, so the file is 15 percent smaller. The two parameters a and b became d and n, the spaces and line breaks are gone, and the code still adds 2 and 3 and prints 5.
The Load Sample button shows the same effect on a longer file. Its 252 character sample, a greet function with a template literal and a URL string, minifies to 146 characters, about 42 percent smaller. Your own saving depends on how much of your file is comments, spacing, and long names: a heavily commented file shrinks a lot, while a file that is already tight shrinks only a little. The tool shows your exact saving under the output box, so you never have to guess.
A minifier and a beautifier do opposite jobs on the same code. A minifier makes JavaScript smaller and harder to read by removing spaces, comments, and long names. A beautifier makes JavaScript bigger and easier to read by adding them back. You minify when a file is ready to publish, and you beautify when you need to read or fix code that someone else minified.
Use the JavaScript Beautifier when a minified file lands on your desk and you need to understand it. Keep your readable copy for editing, publish the minified copy, and come back to the beautifier whenever you need to read it again.
Minifying and gzip are two different savings that stack. Minifying shrinks the code itself, while gzip compresses whatever bytes are left when the file travels from the server to the browser. Minify first, then let the server compress the result: the two together save more than either one alone.
One warning: the raw saving this tool shows is larger than the transfer saving. Gzip is very good at squeezing out repeated spaces and long names on its own, so the transfer saving is always smaller than the raw saving. The minified file is still worth shipping, but judge the download by the compressed size your server actually sends, not by the raw size alone.
This page is the quick way to minify one file, but a build step does the same job automatically for a whole project. Terser itself runs from the command line, and so does esbuild:
npx terser app.js -c -m -o app.min.js
npx esbuild app.js --minify
In the Terser command, -c turns on compression and -m turns on mangling, the same two behaviours this page applies. The esbuild command does both in one flag. If you use VS Code, you do not need a command at all: most JavaScript build tools minify your files when you build for production, so the minified file is produced for you.
Minifying has limits, and this page is honest about them.
Yes, it is completely free with no sign up.
Yes. Minifying removes comments and extra whitespace, shortens local variable names, and simplifies the code itself, for example by removing dead code and folding constants. Your code keeps the same logic and behavior.
No. Text inside strings, template literals, and regular expressions is left untouched, even when it looks like a comment or a division sign.
Keep it on for the smallest file size. Turn it off only if you need readable variable names in the output, for example while debugging.
No. All minifying happens in your browser on your own device, so your code never leaves your computer.
The tool shows a clear error message and keeps your input untouched, so you can fix the error and try again.
No. Terser only accepts plain JavaScript, so TypeScript and JSX files must be compiled to plain JavaScript first. Paste the compiled output here to minify it.
No. This tool produces minified code only, with no source map file. Keep your original readable file, because the minified output cannot be mapped back to it.
It depends on your code. Files with many comments, long names, and generous spacing shrink the most. The worked example on this page went from 60 characters to 51 characters, 15 percent smaller, and the Load Sample file went from 252 characters to 146 characters, about 42 percent smaller. The tool shows your exact saving under the output box.
Yes, when Strip comments is checked, every comment is removed, including licence banners that start with /*! and notes marked @license or @preserve. If your file carries a licence notice that must stay in the shipped code, uncheck Strip comments first: with the box unchecked, those licence comments are kept.
No. There is no option to drop console calls on this page, so console.log lines stay in the output. Remove them before you paste your code, or use the Terser command line with the drop console setting.
If you want to test or edit your code before shrinking it, try the online code editor to write and preview it first.