Code Minifier

Shrink CSS, JavaScript, HTML, JSON and XML by removing comments and whitespace, and see how much you saved. Runs entirely in your browser.

Paste your CSS, JS or HTML → click minify → copy the smallest working version.

Paste code to strip it down for production — minification runs locally in your browser and nothing is uploaded.

Minification here is text-based (removing comments and whitespace). It's reliable for most code, but for complex JavaScript with regex literals or template strings, test the output before shipping — your original stays in the box above untouched.

This is a fast, safe structural minifier (it strips comments and needless whitespace). It is not a full compiler like Terser — it won't rename variables or do advanced optimisation, so the output stays behaviourally identical.

Frequently asked questions

Is the minified JavaScript safe to run?

Yes. The JS minifier only strips comments and collapses whitespace while preserving strings, template literals and regex contents, so behaviour is unchanged. It doesn't rename variables, so it won't break references — but for production builds a full tool like Terser compresses further.

Does minifying JSON validate it?

Yes. JSON is parsed and re-serialised, so invalid JSON is reported as an error rather than silently mangled.

Will HTML minifying break my page?

It removes comments (keeping IE conditional comments) and collapses whitespace between tags. This is safe for typical markup, though be mindful of significant whitespace inside <pre> or <textarea>.

Is my code uploaded?

No. All minification happens locally in your browser, so you can safely paste proprietary or sensitive code.

What this minifier does

Minification is not the same as HTTP compression. Minification removes whitespace and comments from the source text itself, so the file you download is smaller and still valid code. That is different from HTTP compression (gzip or Brotli), which a web server applies on top of the file during transfer. The two work together rather than replacing each other, and minified output should still be tested before use.

Why websites began shrinking source files

As the Web grew from small documents into applications, scripts and style sheets became larger. Minification removes unnecessary characters such as comments and formatting whitespace to reduce transfer size without intentionally changing behavior.

Minification is not compression

Minification rewrites source into a smaller textual form. Network compression such as gzip or Brotli works differently by encoding repeated patterns more efficiently. Production sites often benefit from both.