Minify JavaScript Online
Remove extra spaces, line breaks and comments from your JavaScript code. Minified scripts are smaller to download and are commonly used in production websites and web applications.
Minify your JavaScript code to reduce file size and speed up your website. Fast, free and no signup.
Paste your code or upload a .js file from your device.
Pick compression, variable shortening and comment options.
Copy the minified code or save it as a .min.js file.
Looking for a free JavaScript Minifier? Minify JS online with our easy-to-use tool. Paste your JavaScript code or upload a file, choose your options, and get a smaller, production-ready version in seconds. There is nothing to install and no account to create. Whether you want to speed up your website, reduce page weight, or prepare scripts for deployment, this online JS minifier makes the process simple. Copy the result or download it as a .min.js file.
This JS minifier is also a JavaScript compressor and a quick way to reduce JavaScript file size without a build tool. Web developers, WordPress site owners and SEO specialists use it to speed up pages, improve Core Web Vitals and prepare scripts for production without setting up bundlers, task runners or command-line tools. It runs in your browser on Windows, Mac, Linux, Android and iPhone, and your code is not uploaded.
Remove extra spaces, line breaks and comments from your JavaScript code. Minified scripts are smaller to download and are commonly used in production websites and web applications.
Go beyond whitespace removal. The tool can simplify expressions and shorten local variable names to reduce the final file size even more, while keeping your code working the same way.
See the original size, the minified size and the percentage saved right after minifying. Smaller JavaScript files can help pages load faster, especially on slow connections.
Minifying JavaScript online is a straightforward process. You do not need a build tool or command line setup to shrink a single script. Follow these simple steps to minify your JS code.
If your code contains a syntax error, the tool shows an error message with the line and column so you can fix it and try again.
Minification rewrites your code into a more compact form without changing what it does. Typical changes include removing comments, spaces, tabs and line breaks, and shortening the names of local variables and functions.
Global names and properties are left alone, so your scripts keep working with the rest of your page.
Smaller JavaScript files transfer faster and take less bandwidth, which can improve page loading speed and the experience of your visitors. Minifying scripts is a common step before publishing a website, a plugin or a web application.
Keep your original, readable source file for editing. Use the minified version only for production, because minified code is difficult to read and debug.
Here is a small, readable function with a comment, indentation and a console.log call.
function calculateTotal(items) {
// add up all prices
var total = 0;
for (var i = 0; i < items.length; i++) {
total += items[i].price;
}
console.log("Total:", total);
return total;
}
After minifying with compression and variable shortening turned on, the output is similar to the line below. The exact result depends on your options.
function calculateTotal(t){for(var o=0,r=0;r<t.length;r++)o+=t[r].price;return console.log("Total:",o),o}
The tool shows the original size, the minified size and the percentage saved, so you can see the effect of each option straight away.
Each option changes how aggressively the code is reduced. The table below explains them in plain words.
| Option | What it does | When to use it |
|---|---|---|
| Compress code | Simplifies expressions and statements into shorter equivalents. | Almost always. It gives a smaller file than whitespace removal alone. |
| Shorten variable names | Renames local variables and function parameters to a, b, c and so on. | Production builds where you want the smallest possible file. |
| Remove console.log | Strips console calls from the output. | Final production code, so debug messages do not reach visitors. |
| Keep license comments | Preserves @license and /*! */ comments. | Open-source code and libraries that legally require their license text. |
| Upload .js file | Loads a script from your device into the editor. | Large files that are slow to paste. |
JavaScript is one of the heaviest resources on many pages. The browser has to download it, parse it and run it, so smaller scripts help pages become interactive sooner. This can support better Core Web Vitals and a better experience on slow mobile connections, which is also good for SEO.
Minification is only one tool for faster pages. The table below shows how it fits with other common techniques.
| Technique | What it does | Works well with minification |
|---|---|---|
| Minification | Removes whitespace and comments and shortens names. | This is the base step. |
| Gzip or Brotli | Compresses files while they travel from the server to the browser. | Yes. Minify first, then let the server compress. |
| Browser caching | Lets returning visitors reuse a file they already downloaded. | Yes. Use versioned file names such as app.min.js. |
| defer and async | Stops scripts from blocking the first render of the page. | Yes. Smaller scripts also run sooner. |
| Code splitting | Loads only the code a page needs. | Yes. Minify each file separately. |
| Term | Goal | Changes the code? | Notes |
|---|---|---|---|
| Minify | Reduce file size | Yes, only the text layout and local names | Keeps the same behavior. The code can still be read after beautifying. |
| Compress (gzip, Brotli) | Reduce transfer size | No, the server packs the file and the browser unpacks it | Works on top of minification. |
| Obfuscate | Make code hard to understand | Yes, heavily | Can slow code down. Minification is not a security feature. |
If your goal is speed, minify and compress. If your goal is to hide secrets, remember that anything sent to the browser can be read, so never place passwords or private keys in JavaScript.
Minified code behaves like the original in almost every case. A short checklist keeps surprises away.
If your code has a syntax error, the minifier stops and shows a message with the line and column. The table lists the most common causes.
| Message or symptom | Usual cause | How to fix it |
|---|---|---|
| Unexpected token | A stray character, missing comma or missing bracket near the reported position. | Check the line and column shown, then fix the character before it. |
| Unterminated string | A quote that was opened but never closed. | Close the string or escape the quote inside it. |
| Unexpected end of input | A missing closing brace or parenthesis. | Count your opening and closing brackets. |
| Output is much bigger than expected | Comments or license text are being kept. | Turn off Keep license comments if they are not required. |
| Page breaks after minifying | Code depends on global names or on function names as text. | Turn off Shorten variable names and test again. |
The JavaScript minifier works in any modern browser, so you can minify JS online on Android, iPhone, Windows, Mac and Linux. Whether you search for a JS minifier for Chrome, a JavaScript compressor for Mac or a quick fix for a slow page from your phone, the steps are the same: paste or upload your code, choose your options and download the .min.js file.
Your script is processed in your browser, so it is not uploaded or stored on a server. As a general habit with any online tool, remove API keys, passwords and private tokens from code before you paste it, and keep a copy of the original file.
Minifying is usually the last step before publishing. These related free tools help with the steps before and after it:
Our free JavaScript minifier makes it easy to minify JS online and reduce JavaScript file size in seconds. If you want a JS minifier with no signup, no watermark, no installation and no upload, this page gives you exactly that. Paste your code or upload a .js file, choose your options, click Minify JavaScript and copy or download the result as a .min.js file.
Ready to try it? Scroll back up, add your script and see how many kilobytes you can save.
Find answers to common questions about minifying JavaScript, file size savings and how this tool handles your code.
A JavaScript minifier is a tool that makes your code smaller by removing characters the browser does not need, such as comments, spaces and line breaks. It can also shorten local variable names. The minified code runs the same way as the original but downloads faster.
Paste your code into the editor or upload a .js file, choose your minify options, and click the minify button. When it finishes, copy the minified code or download it as a .min.js file.
Minification is designed to keep behavior the same. Still, it is good practice to test the minified file before using it in production, especially if your code depends on function names, eval or other unusual patterns. If something breaks, try turning off the variable shortening option.
It depends on your code. Files with many comments, long variable names and generous spacing usually shrink the most. The tool shows the original size, the minified size and the percentage saved after every run so you can see the result.
No. The minification runs inside your browser, so your code stays on your device and is not uploaded or stored by this tool. Your browser may load the minification library from a content delivery network when you first use the tool.
Minifying focuses on reducing file size while keeping the code behavior the same. Obfuscating focuses on making code hard to understand and often makes it larger or slower. Minified code can look unreadable, but it is not designed to protect your code from being read.
Not fully. Comments and original variable names are removed, so they cannot be restored. A code formatter can add indentation back to minified code, but always keep your original source file for future editing.
Minify JavaScript, beautify JS code, format and check JavaScript or format JSON in seconds. Explore free developer tools to format, convert and debug your code in one place.
Explore All Developer Tools →