Free JavaScript Minifier & JS Compressor
Make JavaScript files smaller by removing comments and extra spacing. Paste your code or upload a file, choose a mode, then copy the result or download a .min.js file. This online JS compressor is free to use.
Source Editor
JavaScript InputDrag & drop JS file here or click to browse
Supports.js & .txt files (Max 10MB)Compressed Output
Minified OutputOptimization Statistics
What does a JavaScript minifier do?
A JavaScript minifier makes source code more compact. It removes text such as comments and unnecessary spacing so there is less to download. Developers usually keep the readable source file for editing and publish a smaller copy for visitors.
This JS compressor offers two ways to tidy code. Basic mode keeps line breaks. Advanced mode combines lines and removes more spacing around punctuation. The amount saved depends on the code you enter.
How do I minify JavaScript online?
- Add your code. Paste JavaScript into the Source Editor or choose a
.jsor.txtfile. - Choose a mode. Start with Basic if you want to keep line breaks. Choose Advanced for more compact output.
- Select Minify JavaScript. The result appears in the Compressed Output editor.
- Compare the sizes. Check Original Bytes, Minified Bytes, and Space Saved to see what changed.
- Save and test. Copy the output or download the
.min.jsfile. Test it with your page before publishing it.
What does minified code look like?
Here is a small example you can paste into the editor. The comment and spacing help a person read the source.
// Show a welcome message
function greet(name) {
return "Hello, " + name;
}
console.log(greet("Maya"));Advanced mode produces this compact version.
function greet(name){return "Hello, "+name}console.log(greet("Maya"));Both versions print Hello, Maya. Keep the first version as your editable source. The second is easier to distribute when file size matters.
Should I choose Basic or Advanced?
| Mode | What changes | When to use it |
|---|---|---|
| Basic | Removes comments, blank lines, and indentation while keeping line breaks. | For a lighter cleanup when you still want to inspect the lines. |
| Advanced | Joins lines and removes additional spaces around operators and punctuation. | For compact output that you will test before deployment. |
This tool uses text-based compression. JavaScript with regular expressions, template expressions, or syntax that relies on line breaks needs particular care. Run the output and compare its behaviour with your original code.
Will compressing JavaScript make my website faster?
A smaller JavaScript file can reduce the amount of data a visitor downloads. The effect depends on the original file size, network connection, caching, and how the page loads its scripts. Compare the byte counts here, then measure your page after testing the new file.
A file that is already compact may shrink very little. The percentage shown by the tool measures the change for your input.
Is this JS compressor free?
Yes. You can paste code, compress it, and download the result without creating an account. All OperateTools tools are free to use.
Where is my code processed?
Your code is sent to the OperateTools server for compression. The generated file is saved so you can download it. Use sample or public code when trying the tool, and remove passwords, API keys, and other confidential information before submitting a file.
What should I do if the output stops working?
Restore your original file first. Check the browser console for an error, then try Basic mode with a smaller section of the script. If the script depends on syntax this compressor cannot handle, use a JavaScript parser-based minifier in your build process.
For larger projects, the Terser documentation explains compression and mangling options, and MDN explains how JavaScript comments and line breaks are interpreted. Terser options and MDN JavaScript lexical grammar.
Can I make compressed JavaScript readable again?
A formatter can restore spacing and indentation. Comments removed during compression are lost from the output, so keep a copy of the original source.
You can also use the free CSS compressor and HTML minifier when preparing your website files.