JavaScript Minifier
Paste a script to remove comments and unneeded spaces and line breaks. Names and code stay exactly as written, so the script behaves the same.
Use the tool
Loading the tool…
About JavaScript Minifier
Paste JavaScript and get back a smaller version with spaces and comments removed. A smaller file loads faster. Tick the option to keep licence comments, which mark the code's licence.
Worked example
Paste a script with comments. The tool shows how much smaller the output is.
Limits
Minifying can make errors harder to find. Keep your original file for editing, and test the minified code before you use it.
How to use JavaScript Minifier
- Paste your JavaScript.
- Choose whether license comments stay.
- Check the size saved.
- Copy the minified code and test it.
Good to know
- Variable names are not shortened, so the file is larger than one made by a full build tool.
- A line break is kept where removing it could change the meaning, for example in code written without semicolons.
- Template literals, strings and regular expressions are copied unchanged.
- Always test the minified file before you publish it.
Frequently asked questions
Will it break my code?
It only removes comments and spaces, and it checks its own result before showing it. If it cannot do that safely, it says so and shows nothing.
Does it rename variables?
No. Renaming needs a full build tool.
Is my code saved or sent?
The work happens in your browser on this page, and nothing is stored or sent to us.