JavaScript minifier

Paste JS to get a smaller version instantly, with the byte saving shown.

What this minifier does

Removes // and /* */ comments and collapses whitespace while respecting strings, template literals and regex literals. Line breaks that may be needed for automatic semicolon insertion are kept, so code without semicolons still works. It does not rename variables; for production bundles use a full minifier such as a bundler's built-in one.

Is minification worth it?

Minification typically trims 10–40% of a text file. With gzip or Brotli compression on the server the gain shrinks, because compression already removes repetition, but minified files still compress slightly smaller and parse a little faster.

Other minifiers

CSS minifier · HTML minifier

Frequently asked questions

Can minified code be reversed?
Formatting can be restored with a formatter, but removed comments are gone. Keep your original source files.
Will it break my code?
The rules are deliberately conservative. Still, test the result, especially with unusual syntax.