All tools run in your browser — your files never leave your device.
All tools154

Developer & Security

Code Minifier

Strip comments and whitespace from CSS, JS and HTML safely.

What it does. A code minifier removes characters that a parser ignores — comments, indentation, line breaks and redundant whitespace — without changing what the code does. This tool performs conservative minification on CSS, JavaScript and HTML, typically cutting 25–45% of the bytes. It runs in your browser.
Runs in your browserNothing uploadsNo signupWorks offline

How to use Code Minifier

  1. Paste your CSS, JavaScript or HTML, or let the tool detect the language.
  2. Review the size comparison showing original, minified and estimated gzipped bytes.
  3. Copy the minified output or download it as a file.

What this tool does, and what it deliberately does not

Being precise about the boundary matters, because "minifier" covers two quite different classes of tool.

This one does safe minification: it strips comments, collapses whitespace runs, removes line breaks where the grammar permits, drops the final semicolon in CSS blocks, and shortens hex colors where equivalent. Every transformation is provably behavior-preserving.

It does not do mangling: renaming local variables to single letters, dead code elimination, tree shaking, constant folding, or scope hoisting. Those require full AST construction and scope analysis, and getting them wrong breaks code in ways that only surface in production.

For a build pipeline, use esbuild, Terser or SWC — they do the full job and they are correct. This tool is for the case where you have a snippet, no build step, and you want it smaller without risk.

How much smaller will my code get?

How much smaller will my code get?
LanguageTypical reductionPlus gzipMain saving
CSS25–35%80–85%Indentation and comments
JavaScript (unmangled)20–30%75–82%Comments and formatting
JavaScript (with mangling)45–60%82–88%Variable renaming — not done here
HTML10–20%70–80%Inter-tag whitespace
JSON15–30%85–92%All whitespace

The gzip column is the one that matters for a website, and it explains why minification is less dramatic than it appears. Compression algorithms already handle repeated whitespace efficiently, so minifying before gzipping typically saves an additional 5–12% rather than the headline 30%. It is still worth doing — it is free — but it is not where the big wins are.

Will minifying break my code?

Not with the transformations this tool applies, but there are three cases worth knowing about generally.

The first is automatic semicolon insertion in JavaScript. Code that relies on ASI can break when line breaks are removed. This tool preserves line breaks wherever removing one would change parsing, which is why the JS reduction here is lower than an aggressive minifier’s.

The second is significant whitespace in HTML. Whitespace between inline elements is rendered, so collapsing it can visibly close a gap between two words. Content inside <pre> and <textarea> is preserved verbatim for the same reason.

The third is conditional comments and license headers. Comments beginning /*! are preserved by convention, because many licenses require the notice to survive minification.

Should I minify by hand at all in 2026?

For a project with a build step, no — your bundler already does it, better, as part of the build.

The cases where a standalone minifier is genuinely useful are narrower but real: a snippet going into a CMS field or a Shopify theme, an inline script for a landing page with no toolchain, a WordPress custom CSS box, an email template, or a quick check of how much a file would shrink before deciding whether to set up tooling at all.

That last one is the most common. Minify the file here, look at the numbers, and decide whether a build step is worth the setup.

Frequently asked questions

Does it rename variables?

No, deliberately. Variable mangling requires full scope analysis and is where naive minifiers break code. Use esbuild or Terser in a build pipeline if you need it.

Can I un-minify code?

You can reformat it — a beautifier restores indentation. You cannot restore comments or original variable names, because those bytes are gone.

Does it preserve license comments?

Yes. Comments starting with /*! are kept, following the convention every major minifier uses.

Is minified code faster to run?

Marginally. It parses slightly faster because there is less to scan, but execution speed is unchanged. The real benefit is transfer size.

Should I minify before or after gzip?

Before. Minify at build time, then let the server gzip or Brotli the result. The two are complementary.

Does it handle SCSS or TypeScript?

No. Those need compilation first. Compile to CSS or JavaScript, then minify the output.

Is my source code uploaded?

No. The tokenizer runs in this page — safe for proprietary code.

Guides for Code Minifier