JavaScript files shrink dramatically when comments, whitespace and long local variable names are removed — but doing that by hand, or with simple text replacement, breaks code. This minifier uses Terser, a real JavaScript parser, running entirely in your browser. It understands the language, so it can safely compress your script and shorten local names while keeping the program behaving exactly the same.
Why a Parser Matters
Naive minifiers fail on template literals, regular expressions and modern syntax like classes, optional chaining and async functions, because they cannot tell code from text. Terser parses the file into a syntax tree first, then writes it back in the tightest correct form. It also removes unreachable code and simplifies constant expressions where that is safe. The tool shows the original and minified sizes side by side, and if your input has a syntax error, you get the parser message instead of a silently broken file.
How to Minify JavaScript
- Paste your JavaScript into the input box.
- Choose whether to also mangle (rename) local variable names.
- Click minify and wait for the parser to finish.
- Compare sizes and copy the result, or download the .js file.
- Test your page with the minified file before going live.
Where It Fits in a Build
- Preparing scripts for production without a build pipeline.
- Shrinking standalone widgets, snippets and bookmarklets.
- Reducing page weight for faster loads on mobile networks.
- Cleaning third-party code samples before embedding.
Frequently Asked Questions
What is the difference between compress and mangle?
Compress removes whitespace, comments and dead code. Mangle additionally renames local variables to short names, which saves more space but makes debugging harder.
Does it support modern JavaScript?
Yes. Terser handles current syntax including modules, classes, template literals and optional chaining.
Should I keep the original file?
Always. The minified file is for serving; the original is the one you edit, read and debug.