Compress CSS by removing whitespace, comments

Minify CSS by removing safe comments and formatting bytes while preserving declarations.

freeworks offlinenothing uploaded
ToolCSS Minify
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

Comments and unnecessary whitespace are removed, safe color or zero-unit shortenings may be applied, and declaration order stays intact. Strings, URLs, custom properties, and calc expressions are protected.

  • Whitespace and comments are safe size wins.
  • Value shortening is conservative because CSS context matters.

Worked example

Minify a stylesheet
Remove whitespace and comments from CSS
Input
											/* Reset */
body {
  margin: 0;
  padding: 0;
}

.container {
  max-width: 1200px;
}
										
Output
												body{margin:0;padding:0}.container{max-width:1200px}
											

When to use this

Production bundles, critical-CSS tests, and asset pipelines minify stylesheets.

Edge cases

  • Whitespace inside strings and data URLs is content.
  • Custom properties preserve token text for later substitution.
  • A zero unit is not removable for every property.

References