Leaner JavaScript, Faster Pages
JavaScript is usually the heaviest text a web page downloads, and unlike images, the browser has to read and run every byte of it before the page becomes fully interactive. Comments, indentation and blank lines make code pleasant to work on, but visitors never see them. On a slow mobile connection they add real waiting time.
A JavaScript minifier removes those extras and produces a compact file that runs exactly the same way. Paste your code into the box above and the minified version appears instantly on the right, along with how much you saved. Everything is processed inside your browser, so your code is never uploaded or stored.
How to Use the JavaScript Minifier
- Paste your code into Input JavaScript, open a .js file, or drag one onto the box.
- The minified result appears on the right straight away. A green Verified label confirms it was checked.
- See the original, minified and gzipped sizes in the Size Savings panel.
- Click Copy, or Save to download a .min.js file.
- To read minified code instead, switch the output to Beautify.
If your code has a mistake, such as a missing bracket, the tool tells you the exact line and column so you can fix it quickly.
Verified: Same Code, Smaller File
JavaScript has a few traps that make careless minifying dangerous. The best-known is automatic semicolon insertion. When you leave out a semicolon, the language sometimes adds one for you at a line break, and sometimes doesn't. Remove the wrong line break and two separate statements can quietly merge into one, which breaks the page in ways that are hard to track down.
This tool takes a careful approach. It reads your code with a full JavaScript parser, so strings, regular expressions, template literals and comments are recognised correctly instead of guessed at with patterns. It only removes a line break where the language guarantees it makes no difference. Then it parses the result again and compares the two programs, piece by piece. If they don't match perfectly, it falls back to a safer mode that keeps the important line breaks, and if even that can't be proven identical, it hands back your original code untouched rather than risk breaking it.
It was tested on large open-source libraries, including Markdown parsers and a maths typesetting library of over 600 KB, and every result matched its original exactly.
What Changes and What Doesn't
- Removed: comments, indentation, blank lines and spaces that the language doesn't need.
- Kept: license comments that start with
/*!or contain@license, which most open-source licences require you to keep. - Untouched: the contents of strings, template literals and regular expressions, so text like
"a // b"never loses half its value. - Not renamed: variable and function names stay as they are. Renaming can save more bytes, but it also breaks code that other scripts rely on, so this tool leaves names alone.
Modern syntax is fully supported, including classes, private fields, arrow functions, async and await, optional chaining, modules with import and export, and top-level await.
Beautify Minified Code
Ever opened a script and found one endless line of code? Switch the output to Beautify and the tool spreads it out with consistent indentation, one statement per line and readable spacing around operators. It is a handy way to understand how a third-party widget works, to debug a production error, or to review code before you add it to your site. Beautified output is verified in the same way as minified output.
How Much Will You Save?
Well-commented, hand-written code often shrinks by 25 to 45 percent. Code that is already compact saves less. Your server likely compresses scripts with gzip or Brotli too, and the Size Savings panel shows the gzipped figure so you know what visitors really download.
Tools that also rename variables, like those built into big frameworks, can shrink files further. For many websites, though, the safest win is simply removing what was only ever there for humans, and that is exactly what this tool does.
Smaller scripts also help with Core Web Vitals, the page experience signals Google measures. Less JavaScript to download and parse means the page can respond to the first tap or click sooner, which visitors notice even if they never think about file sizes.
Tips for Using Minified JavaScript
- Always keep your original, readable file and publish the minified copy, named with
.min.js. - Turn on Keep line breaks if you want error messages in the browser console to point at sensible line numbers.
- After replacing a script on your site, open the page and check the browser console for errors before moving on.
- Minify your CSS and HTML as well. Small savings in each file add up across a whole site.