JavaScript Minifier
Shrink JavaScript by stripping comments and whitespace — safely, never breaking it.
How to use the JavaScript Minifier
- Paste your JavaScript on the left.
- Comments and extra whitespace are removed; line breaks are kept so nothing breaks.
- Copy the smaller code.
About the JavaScript Minifier
The JavaScript Minifier shrinks your code by stripping comments and trimming whitespace, but it is built around one guiding principle: never break your code. It is deliberately conservative. Rather than collapsing everything onto one line, it keeps line breaks, which means it can never accidentally join two statements and trip up JavaScript automatic semicolon insertion (ASI) the way an aggressive tool sometimes can.
It is also careful about context. Strings, template literals and regular-expression literals are correctly skipped, so comment-like sequences and stray whitespace inside them are left exactly as written and never corrupted. The honest trade-off is that this is safer but less aggressive than a full compressor such as Terser or UglifyJS: you get a smaller file that is guaranteed not to change behaviour, but not the absolute smallest possible output.
Everything runs in your browser, so nothing you paste is uploaded. If you need to read minified code again, the JavaScript Beautifier restores clean indentation, and to compress the rest of your front end use the CSS Minifier alongside it.
Frequently asked questions
Why does the output still contain line breaks?
Keeping line breaks is a safety feature. It means the minifier can never merge two statements onto one line, so it cannot break JavaScript automatic semicolon insertion, which is a common way aggressive minifiers introduce bugs.
Is it as small as Terser or UglifyJS?
No, and it does not claim to be. Those compressors are more aggressive and can produce smaller files. This tool prioritises safety over maximum compression, trading a little size for a guarantee that your code keeps working.
Does it damage strings or regular expressions?
No. It correctly skips strings, template literals and regex literals, so comment-like text or whitespace inside them is preserved exactly. Only genuine comments and insignificant whitespace are removed.
What does it actually strip?
It removes comments and trims unnecessary whitespace while keeping line breaks intact. The result is a smaller file whose behaviour is identical to your original source.
Is my code uploaded anywhere?
No. Minification happens entirely in your browser and nothing is sent to a server, so it is safe to use with private or proprietary JavaScript.

