JS minifier

Paste code into this free js minifier to strip whitespace, comments, and optional semicolons. Get a smaller file ready for production without signing up.
How the js minifier works
It builds an abstract syntax tree from your raw input. The parser ignores your formatting choices entirely. Then it regenerates the code using the absolute minimum number of characters required to keep the logic intact. Variable names stay exactly as you wrote them. This means the output remains perfectly readable if you run it through a beautifier later.
You will see the biggest size drops from stripping block comments and line breaks. The tool also removes spaces around operators where the grammar allows it. It drops optional semicolons before closing braces. These tiny savings add up fast across a large codebase.
When you need an online js minifier
You need this when shipping a quick prototype to a static host. Dropping a single uncompressed script into an index file works fine locally. It chokes on slow mobile networks once you add a few dependencies. Compressing the payload before upload fixes the latency. Network transfer time drops significantly when you strip out every unnecessary byte.
Build tools handle this automatically for complex projects. You only reach for a standalone web tool when you lack a build pipeline or need to test a quick fix. Paste a messy script from a forum, compress it, and drop it into your browser console.
- Deploying vanilla scripts to basic static hosting without webpack or vite.
- Testing a compressed snippet directly in the browser developer console.
- Shrinking a single file before emailing it to a client or colleague.
Limits of javascript minification
This tool doesn't rename your variables to single letters. That process is called mangling, and it requires deep scope analysis to avoid breaking global references. You must use a dedicated build tool if you want aggressive variable shortening.
It also will not fix syntax errors in your original code. If you miss a closing bracket, the minifier just fails or produces broken output. Always validate your script in a linter before trying to shrink it. The tool assumes your input is already valid. Garbage in means garbage out, even with automated compression.
How to use the js minifier
- Paste your raw javascript source code into the main input text area.
- Click the minify button to process the text and strip unnecessary characters.
- Review the compressed output in the result box to ensure it looks correct.
- Copy the minified string and save it to your production javascript file.
Minified versus unminified javascript
Here is a quick comparison of what changes when you run your code through the compressor.
| Feature | Unminified | Minified |
|---|---|---|
| Whitespace | Preserves all spaces, tabs, and newlines | Removes all non-essential whitespace |
| Comments | Keeps single-line and block comments | Strips all comments entirely |
| Variable names | Uses original developer-chosen names | Keeps original names without mangling |
| Semicolons | Includes optional trailing semicolons | Omits semicolons where grammar permits |
Frequently asked questions
- Is this js minifier completely free to use
- Yes. The tool is entirely free and requires no account creation. You can run as many compressions as you need without hitting a paywall.
- Does it mangle variable names to save more space
- No. This tool only removes whitespace and comments. It doesn't perform scope analysis or rename variables. You need a dedicated build tool for true mangling.
- What happens if my javascript has a syntax error
- The minifier will likely fail to parse the input or return broken code. It doesn't fix missing brackets or typos. Run your code through a linter first.
- Can I minify javascript files directly from my computer
- You cannot upload files directly. You must open your local file in a text editor, copy the contents, and paste them into the web interface.
- Will minifying break my source maps
- Yes. Minification changes line numbers and character positions entirely. You must generate new source maps using a build tool that supports them if you need to debug the compressed code. The browser won't map the minified file back to your original source without that extra step.
Share
Similar tools
Minify your HTML by removing all the unnecessary characters.
Minify your CSS by removing all the unnecessary characters.
Popular tools
Check if the URL is cached or not by Google.
Check for 301 & 302 redirects of a specific URL. It will check for up to 10 redirects.
Get approximate IP details.
Take an IP and try to look for the domain/host associated with it.