Skip to content

JavaScript Minifier

Minify JavaScript by removing comments and whitespace while preserving string literals

Quick JS compression for one-off files

Your build pipeline has Terser. Your project uses Vite. But right now you’ve got a standalone script, maybe a bookmarklet, maybe an inline <script> for an email template, maybe a utility file that lives outside any build system, and you just want it smaller.

Paste it here. Comments get stripped (both // and /* */), extra whitespace collapses, empty lines vanish. String literals, single-quoted, double-quoted, template literals with ${expressions}, are left completely untouched. You see the original size, minified size, and percentage saved.

What this does and doesn’t do

This is basic minification: comments and whitespace removal. It doesn’t rename variables, eliminate dead code, fold constants, or do the fancy stuff Terser and esbuild handle. For production bundles, use those tools in your build pipeline.

But for quick, ad-hoc tasks? This is faster than configuring a CLI. Lighthouse flagged your inline script as unminified. You’re building a bookmarklet and need it compact. You’re sharing a snippet somewhere with a character limit. Paste, click, copy.

String safety

The minifier respects string contexts. A // inside a quoted string won’t be mistaken for a comment. Template literals with interpolation are preserved. That said, always test your minified output before deploying, edge cases exist in any basic implementation.

The numbers

Typical reduction: 10-30%. A 50KB file with JSDoc comments might drop to 35KB. A 5KB snippet with minimal comments might only save a few hundred bytes.

For the reverse, making minified JS readable, use the Code Formatter.

FAQ

Does it rename variables?

No, that’s mangling, which requires static analysis. Terser, esbuild, and SWC handle that. This only strips comments and whitespace.

Template literals?

Fully preserved, including ${} interpolations. Only whitespace and comments outside string contexts are touched.

Is my code safe?

Client-side JavaScript, nothing leaves your browser. Fine for proprietary code.

Will it break my code?

String literals and code structure are preserved. But this is a basic implementation, always test the output before production use.

javascript minifier minify compress optimize

Related Tools

More in Developer Tools