JavaScript Minifier
Minify JavaScript online for free with Terser: shorten variable names, fold constants, drop dead code and console calls, and beautify minified JS back into readable code. 100% in your browser, no signup.
Your result will appear here.
⚡ Minifying shrinks a script by removing comments and whitespace, shortening local names and folding constants, so the file downloads sooner and parses faster. The code still runs exactly the same. Terser parses your code into a real syntax tree first, so it never breaks a string, a template literal or a regex.
🔒 Privacy: minifying and beautifying run locally in your browser. Your code is never uploaded, stored or seen by anyone else.
More developer tools
How this calculator works
A JavaScript minifier shrinks a script by removing everything the browser does not need to run it: comments, whitespace, line breaks and long local names. The code runs exactly the same, but the file is smaller, downloads sooner and parses faster, which matters most on slow mobile connections where every kilobyte delays the first interaction. Paste your code here, or upload a .js file, and the minified version appears instantly with the byte count before and after and the percentage you saved.
This tool minifies with Terser, the same parser-based minifier that powers many build tools, running entirely in your browser. Terser first parses your code into a real syntax tree, so it understands strings, template literals, regular expressions and comments instead of guessing with text replacement. That is how it can safely shorten local variable names, fold constants like 2 + 3 into 5, drop dead code that can never run, and remove console calls on request, while keeping license comments that start with /*! when you ask it to. If Terser cannot load, the tool falls back to a safe scanner that only strips comments and whitespace and never renames anything, and it says so on screen.
The beautify mode does the reverse: it turns a minified file back into indented, readable code, one statement per line, which is handy when you inherit a minified chunk from a legacy CDN or a copied DevTools panel and need to read it. A bundler such as esbuild or webpack will usually save more on a full project, because it bundles many files, splits code and understands source maps, but for a single file this tool is faster: no install, no config, no upload. Keep in mind that real transfer sizes will be smaller again once the server applies gzip or Brotli, so the percentage shown here is the raw saving before compression. Your code never leaves your device.
