Developer Tools

JavaScript Minifier

Shrink JavaScript with a comment-stripping minifier that respects strings and regex.

Conservative minifier — always test the minified output before using it. For production builds, use Terser or esbuild.
Paste JavaScript and press Minify to see size savings.

What is a JavaScript minifier?

JavaScript minification shrinks a script by removing comments and unnecessary whitespace while keeping the program's behavior identical. This minifier is deliberately conservative: instead of renaming variables or restructuring code like production tools do, it runs a small state machine over the source that understands strings, template literals, regular expressions, and comments. That means a // inside a string is never mistaken for a comment, and a / starting a regex is never mistaken for division. The result is smaller, safe-to-test output — with a clear warning that production builds deserve Terser or esbuild.

How to use this tool

  1. Paste your JavaScript into the input box.
  2. Press Minify — comments are stripped and whitespace is collapsed wherever the state machine proves it safe.
  3. Check the size-savings card, then copy the output or download it as a .js file.
  4. Test the minified script in a browser or with node before deploying it anywhere.

Key features

Common use cases

Practical tips

Frequently Asked Questions

Will minified JavaScript run exactly like my original?
It should — the minifier only removes comments and provably unneeded whitespace, and it protects strings, template literals, and regex. But 'should' is not 'guaranteed', so always test the output before production use.
How does it tell a regex apart from division?
It looks at the previous significant token: after (, =, return, and similar contexts a / starts a regex; after an identifier, number, or ) it is division. Keywords like return and typeof are recognized too.
Why are some newlines kept?
JavaScript's automatic semicolon insertion means joining certain lines changes behavior — return\nx must stay on two lines. The minifier keeps a newline wherever removing it could alter semantics.
Does it rename variables like Terser does?
No. This is a conservative whitespace-and-comment minifier only. Real production minifiers also shorten variable names, drop dead code, and need a full parser — use Terser or esbuild for that.
Is my code uploaded anywhere?
No. The state machine runs entirely in your browser, so proprietary or unreleased code never leaves your device.