Toolantern
Home › JavaScript Minifier
Free tool. No sign-up.

JavaScript Minifier

Compress JavaScript for production: strips comments and unneeded whitespace while keeping string literals intact, and reports your exact byte savings.

What the tool does

This minifier removes line and block comments, collapses unneeded whitespace, and strips spaces around operators and punctuation, while carefully preserving string literals, template literals and regexes so your code keeps working.

Worked example

function hello() {
  // greet
  console.log( 'hi' );
}
becomes function hello(){console.log('hi');}: comments and padding gone, logic untouched.

Limits

This is a safe whitespace-and-comment minifier, not a full optimizer: it does not rename variables or restructure code. For aggressive tree-shaking use a build tool like esbuild or Terser; for a quick size win on a snippet, this is enough.

Planning estimate only. Results use the list prices shown and may differ from your actual bill. Terms

Frequently asked questions

Is it safe to minify any JavaScript?

Whitespace and comment removal is safe for normal code. This tool preserves strings, template literals and regex literals, which is where naive minifiers break code. Still, test the output before deploying.

How much smaller does JS get?

Typically 15 to 35 percent for hand-written code, mostly from stripped comments and indentation. The tool reports your exact savings.

Does it obfuscate my code?

No. Minified code is still readable with a formatter. Real obfuscation needs a dedicated obfuscator, and even that only slows down a determined reader.

Is my code sent to a server?

No. Minification runs locally in your browser, so proprietary code stays private.

More free tools