Skip to content
TypeParser
All tools

JavaScript Minifier

Minify JS by stripping comments and whitespace.

beats jscompress.com edge: Live size delta + comment-aware
input.js
paste JS
Guide

About JavaScript Minifier

Strip comments, whitespace, and trailing semicolons from JavaScript. Reports byte savings and ratio. Useful for ad-hoc size estimates and small embeds. For production minification with mangling and dead-code elimination, use a real bundler (esbuild, swc, terser).

When this is the right tool

  • Inline scripts in HTML — small and infrequently changed
  • One-shot embeds — analytics snippet, single-purpose script
  • Quick size estimate — see how much your file compresses before deciding to bundle
  • Removing comments before sharing — strip TODOs and NOTEs from a snippet

For application code, use a real bundler. The size difference is dramatic.

What gets stripped

  • Single-line // and block /* */ comments
  • Whitespace between tokens (kept where required for parsing)
  • Trailing semicolons inside blocks (where ASI handles them)
  • Empty lines

What does not change:

  • Variable names
  • Function names
  • String contents (including comments inside strings)
  • Logic structure

Common workflows

Embed a small script in HTML. Minify, paste inside <script>...</script>. Saves bytes without a build step.

Estimate compression. Drop your file in, see byte savings. If saving is meaningful, your gzip will get even more — set up a real bundler.

Strip comments before sharing. Minify, then re-format with JS Formatter. Result: clean code without the developer’s TODOs.

Frequently asked questions

Is this real minification?
It strips noise (whitespace, comments) but does not mangle identifiers or eliminate dead code. For a 70-90% reduction, use a bundler. For a 20-40% reduction in size, this tool is enough.
Will it break my code?
No — the operation is structurally safe. Comments and whitespace are removed; structural code stays.
Does it handle JSX?
Yes — strips JSX comments and reflows. JSX-aware so {/* comment */} drops cleanly.
How much smaller will my code get?
Typically 20-40%. Highly commented code saves more; minified code saves less.
For production, what tool?
esbuild (fastest), swc (Rust-based, fast), terser (mature, slow but exhaustive). Each gives 70-90% reduction with full mangling and tree-shaking.
Round-trip with the formatter?
Yes. Format → minify → format gives back the same logical code with consistent layout.

Related tools

Last updated: 2025-01-15