JavaScript Minifier
Paste your JavaScript code to minify by removing comments, whitespace, and unnecessary characters
Paste your JavaScript, hit one button, and get a smaller file — comments gone, whitespace crushed, unnecessary characters stripped. No build tools, no config files, no npm install. And everything runs in your browser. Nothing gets uploaded.
How It Works
The minifier parses your JavaScript into an abstract syntax tree using Acorn, then rebuilds it without the extras. Comments get deleted, whitespace between tokens gets collapsed to the bare minimum, and semicolons are cleaned up. The result is functionally identical code that weighs less on the wire.
Examples
Stripping comments from a utility function
You documented every line during development. Production doesn't need those comments shipped to users.
// Calculate tax amount
function calcTax(price, rate) {
// Default rate is 8.5%
const r = rate || 0.085;
return price * r;
}
function calcTax(price,rate){const r=rate||0.085;return price*r}
Shrinking an event handler block
Inline scripts in HTML emails or landing pages — every byte counts when you can't use external files.
document.addEventListener("DOMContentLoaded", function () {
const btn = document.getElementById("submit");
btn.addEventListener("click", function (e) {
e.preventDefault();
console.log("clicked");
});
});
document.addEventListener("DOMContentLoaded",function(){const btn=document.getElementById("submit");btn.addEventListener("click",function(e){e.preventDefault();console.log("clicked")})});
Cleaning up a config object
Config files tend to accumulate block comments and trailing whitespace over months of edits.
/**
* App configuration
* Last updated: 2024-11-03
*/
const config = {
apiUrl: "https://api.example.com",
timeout: 5000, // 5 seconds
retries: 3
};
const config={apiUrl:"https://api.example.com",timeout:5000,retries:3};
Who Uses This
Quick-minify a script before dropping it into a CMS that doesn't have a build step.
Squeeze inline JS into HTML emails where every kilobyte affects deliverability.
See what minification actually removes so the concept clicks before learning Webpack.
Ship a landing page with one less build dependency by minifying the JS file manually.
Common Mistakes
The minifier has to parse your code before it can shrink it. A missing bracket or unclosed string will throw an error. Fix the syntax first, then minify.
This tool removes whitespace and comments — it doesn't mangle variable names. For that level of compression, you need Terser or a bundler with tree-shaking.
Running minified code through the tool again won't save more space. If the savings show 0%, the file is already minified. Try the beautifier first if you need to read it.
Technical Details
- Processing: 100% client-side — your code stays in the browser
- Parser: Acorn JavaScript parser (ES2020+ support)
- Browser Support: Chrome, Firefox, Safari, Edge
- Max Input: Limited only by browser memory (tested up to 2MB files)
Frequently Asked Questions
Does minifying JavaScript break my code?
Not if the original code is valid. Minification removes whitespace and comments — it doesn't change logic. That said, always test the minified version. Some edge cases with regex literals or template strings can trip up simpler minifiers.
How much smaller will my JavaScript file get?
Depends on how much whitespace and how many comments your code has. Well-commented source files typically shrink 30-60%. Code that's already fairly compact might only drop 10-15%. The tool shows you the exact percentage right after minification.
What is the difference between minification and obfuscation?
Minification makes code smaller but still readable if you beautify it. Obfuscation rewrites variable names, adds dead code, and makes the logic intentionally hard to follow. This tool minifies only — it won't protect your source from being reverse-engineered.
Is it safe to paste proprietary code into an online minifier?
With this tool, yes. Everything runs in your browser using JavaScript — nothing gets sent to a server. You can verify this by opening your browser's Network tab while minifying. Zero requests go out.
Should I minify JavaScript for a small personal website?
If your script is under 5KB, the savings are tiny and probably won't affect load times. But it takes ten seconds, so why not? For anything over 20KB, minification is worth the effort — especially on mobile connections where every kilobyte matters.