JavaScript Minifier
Remove comments and collapse whitespace in JavaScript, with basic string protection.
Enter your details below.
How to use
- Paste your JavaScript into the box.
- Click Minify JavaScript.
- Check the compact result before using it in production.
About this tool
This tool strips line and block comments and collapses runs of whitespace, then trims spaces around braces, brackets, parentheses, semicolons and commas. Quoted strings, including template strings, are protected first so their contents are not altered. It is a basic minifier: it does not rename variables, remove dead code or handle every edge case, and regular expressions containing comment-like text can still confuse it, so check the result before shipping it.
Frequently asked questions
Does it rename variables?
No. Names are left exactly as written; only comments and whitespace are removed.
What can still go wrong?
Regular expressions that look like comments, and other unusual syntax, can confuse a basic minifier. Treat the output as a draft and test it.