Free JavaScript Minifier
Minify JavaScript in your browser with Terser, the same engine used by major build tools, and get clear error messages with line numbers.
JavaScript Minifier: Minify JavaScript in your browser with Terser, the same engine used by major build tools, and get clear error messages with line numbers. It is free, needs no sign-up and runs in your browser. How to use it: 1) paste your JavaScript code; 2) choose mangle, compress, license comments and module mode; 3) click Minify, then copy or download the minified script. JavaScript cannot be minified safely with simple text tricks, because removing the wrong line break or space can change what the code does. This tool uses Terser, a widely used open source minifier, which parses your code into a syntax tree and rewrites it in a shorter form.
How the JavaScript minifier works
JavaScript cannot be minified safely with simple text tricks, because removing the wrong line break or space can change what the code does. This tool uses Terser, a widely used open source minifier, which parses your code into a syntax tree and rewrites it in a shorter form. Terser loads from the jsDelivr network the first time you click Minify, then runs entirely in your browser.
Options
- Mangle: shortens local variable and function names. Global names are left alone so other scripts still work.
- Compress: removes unreachable code, joins statements and simplifies expressions.
- Keep license comments: keeps comments that start with /*! or contain @license or @preserve.
- ES module: allows import and export statements.
Error messages
If your code has a syntax error, you see the line, column and message from the parser, plus the line of code with a marker under the problem.
Formula
Savings = (original bytes minus minified bytes) divided by original bytes, times 100.
Limitations
The tool needs to download Terser once, so it will not work offline on the first use or if a content blocker stops jsDelivr. Code that relies on function names, such as some frameworks, may need mangle turned off. Keep your original source for editing.
About this tool
The JavaScript Minifier is built and maintained by the Hayyat Networks team, a digital marketing, SEO and web development agency working with businesses in New York and Lahore since 2016. It is part of our free Website Development Tools collection.
- Last reviewed
- CostFree, no sign-up
- Where it runsRuns in your browser
- Checking resultsThe method and a worked example are shown above, so you can verify every result.
- PrivacyIt runs entirely in your browser: what you type stays on your device and is never sent to us.
Spotted a problem or have an idea? Tell us and we will review it.
Link to this tool
Free to share in your blog, course notes or resource list. Copy the link below:
<a href="https://hayyatnetworks.com/free-tools/website-tools/javascript-minifier/">JavaScript Minifier</a> by Hayyat NetworksJavaScript Minifier FAQs
Is it safe to minify JavaScript?
Yes, with a proper parser like Terser. It understands the language, so it only makes changes that keep the same behaviour. Problems are rare and usually come from code that reads function names at runtime. If something breaks, turn off mangle and test again.
What is the difference between minify and obfuscate?
Minifying makes code smaller for faster loading. Shorter variable names are a side effect, not protection. Obfuscation deliberately makes code hard to understand. Neither hides secrets, because anyone can reformat and read the code in their browser. Never put API keys or passwords in front-end JavaScript.
Why do I see a syntax error?
Terser must parse your code before it can minify it. A missing bracket, a stray character or using import without module mode will stop it. The tool shows the exact line and column, so you can fix the issue and try again.
Is my code uploaded?
No. Only the Terser library is downloaded from the jsDelivr content network. Your code is processed in your own browser and never sent to our server or any other service, so it is safe for private projects and client work.
Want our experts to implement these improvements?
Get professional support from Hayyat Networks. Request a free consultation.
