Free Online JavaScript Minifier
Remove comments, whitespace and line breaks from your JavaScript. Free, and it runs in your browser.
🔍 You Can Also Visit More Tools Categories
What Is JavaScript Minification?
JavaScript minification removes characters that are not needed to run your code: comments, extra spaces and line breaks. The result is a smaller file that downloads faster. The code should behave the same, but always test the minified file before using it.
For production websites, a build tool such as Terser or esbuild is more reliable, because it reads your code properly instead of cleaning it with text rules. Use this tool for quick, one-off jobs.
Working on the rest of your page? Try the HTML Minifier and the CSS Minifier.
How to Use the JavaScript Minifier
- Paste your JavaScript into the Original Code box.
- Click Minify Now.
- Check the Minified Code box. It shows the size saved.
- Click Copy Minified or Download File, and save it as a
.min.jsfile.
Is My Code Private?
The minifier runs in your browser using JavaScript, and your code is not sent to our server. JavaScript files often contain API keys or tokens, so remove any secrets before pasting code into an online tool.
JavaScript Minifier Example
Before:
// Add two numbers
function addNumbers(a, b) {
const total = a + b;
return total;
}
console.log(addNumbers(2, 3));
After (typical output):
function addNumbers(a,b){const total=a+b;return total}console.log(addNumbers(2,3));
Things to Check After Minifying
| Item | Why it matters |
|---|---|
| Missing semicolons | Code that relies on automatic semicolon insertion can break when line breaks are removed. Add semicolons before minifying. |
Strings and regex with // | Simple minifiers can mistake // or /* inside a string or regex for a comment. |
| Template literals | Spaces and line breaks inside backticks are part of the text. |
| Debugging | Minified code is hard to read in the browser console. Keep your original file, or use a build tool that creates source maps. |
Frequently Asked Questions
1. What does the JavaScript Minifier do?
It removes comments, extra spaces and line breaks from your JavaScript to reduce the file size.
2. Will my JavaScript still work after minifying?
Usually, but it is not guaranteed. Code that depends on automatic semicolon insertion, or has // inside strings or regex, can break. Test the minified file and keep your original.
3. Is it safe to paste my code here?
The tool runs in your browser and does not send your code to our server. Still, remove API keys, tokens and passwords from your code before pasting it into any online tool.
4. Should I use this tool or a build tool for production?
For production websites, use a build tool such as Terser or esbuild. It is more reliable and can create source maps. This tool is best for quick, one-off jobs.
5. Does minifying JavaScript make my site faster?
A smaller file downloads faster, especially on slow connections. The saving depends on your file. For the best result, also use gzip or Brotli compression, browser caching and remove code you do not use.