Developer Tools

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.

Frequently asked questions

How do I minify JavaScript online?
Paste your JavaScript into the input box, or upload a .js or .mjs file. The minified version appears instantly, with the byte count before and after and the percentage saved. Copy the result or download it as script.min.js. Nothing is uploaded: minifying runs in your browser.
Is minified JavaScript safe? Will it change how my code behaves?
No. Terser parses your code into a real syntax tree before changing anything, so it only shortens local variable names and never touches globals, object properties, strings, template literals or regular expressions. Constant folding and dead-code removal preserve behavior. If your code has a syntax error, the tool shows Terser's error message and returns nothing, so broken code never reaches you silently.
What is the difference between minifying and obfuscating?
Minifying shrinks code for performance: shorter names, no comments, no wasted whitespace. Obfuscating deliberately hides what the code does, with tricks like control-flow flattening and string encryption. Mangled names are not security: anyone can run the code through a beautifier and read it again, so never rely on minification to hide secrets or API keys.
When should I use a bundler instead of this tool?
Use a bundler such as esbuild, webpack, Rollup or Vite when your project has many files, imports, npm packages, code splitting or source maps. For a single file you want smaller right now, paste it here: no install, no config, no upload, and the result is ready in a second.
Does my code leave my browser?
No. Minifying and beautifying run locally in your browser with Terser. Your code is never uploaded, stored or seen by anyone else, which makes the tool safe for proprietary code, though you should still avoid pasting live secrets anywhere you do not have to.
Does it support TypeScript or JSX?
No, this tool works on plain JavaScript only, including ES2020 syntax and ES modules. TypeScript and JSX have to be compiled to JavaScript first with tsc, Babel or esbuild, and then you can minify the compiled output here.
Disclaimer: Results are estimates for planning purposes only and are not financial advice. Actual loan terms, taxes and investment returns vary. Consult a qualified professional before making financial decisions.