tools / js-minify

JavaScript Minifier

Strip comments and unnecessary whitespace from JavaScript, without touching strings, template literals, or regular expressions. Everything runs in your browser.

Input
Output

What does this minifier do?

It removes // and /* */ comments and collapses unnecessary whitespace, while correctly recognizing string, template-literal, and regular-expression boundaries — so a / inside a regex or the contents of a template string are never mistaken for code and altered.

Why not just rename variables too?

Renaming variables and dead-code elimination require actually parsing JavaScript into an AST — well beyond what a browser-side text tool should attempt safely. For production bundles, use a real minifier like Terser or esbuild as part of your build; this tool is for quick, safe whitespace/comment stripping on a snippet.

Frequently asked questions

Will this break a regex literal like /ab+c/g?

No — the minifier tracks what character precedes a / to tell a regex literal apart from division, and copies regex literals through untouched.

Is this as thorough as Terser or esbuild?

No. Those tools parse a full AST and can rename variables, remove dead code, and safely restructure statements. This tool only strips comments and collapses whitespace — safer for a quick browser check, but it won't shrink a file nearly as much as a real build-time minifier.

Is my code uploaded when I use this tool?

No. Minification happens instantly in your browser — nothing is sent to a server.