CSS Minifier

Compress a stylesheet down to the bytes that matter.

Code Formatters Free, no sign-up Runs in your browser

CSS Minifier tool

Options

About the CSS Minifier

CSS Minifier removes everything a browser does not need to parse your stylesheet: comments, the whitespace that made it readable, the semicolon before a closing brace, and the leading zero in values like 0.5em.

Several optional passes go further. Hex colours written in full can be shortened when both digits of each pair match, so #ffcc00 becomes #fc0. Zero values can drop their unit, since 0px and 0 are identical. Empty rules, which usually arrive from a deleted declaration nobody tidied up after, can be removed entirely.

Every transformation here preserves meaning exactly. The tool does not merge rules, reorder properties or combine selectors, because those changes depend on cascade order and can alter which rule wins. A smaller file is not worth a layout that silently changes.

How to use the CSS Minifier

  1. Paste your CSSA full stylesheet or a fragment.
  2. Choose the optional passesShorten hex colours, strip units from zeros, remove empty rules.
  3. Press MinifyThe compact CSS appears with the size comparison.
  4. Copy or downloadTake the minified stylesheet.

Features

  • Removes comments and all unnecessary whitespace
  • Drops the final semicolon in each block
  • Shortens six-digit hex colours where possible
  • Removes units from zero values
  • Removes empty rules
  • Never reorders or merges rules, so the cascade is unchanged
  • Shows original size, minified size and percentage saved

Who uses this tool

The css minifier is used by writers, developers, students, marketers and anyone else who needs the job done once without installing software. Common cases include:

  • Shrinking a stylesheet before deployment
  • Inlining critical CSS into a page head
  • Reducing the size of CSS inside an email template
  • Measuring how much of a stylesheet is comments and whitespace
  • Cleaning up a hand-edited stylesheet

Frequently asked questions

Is minified CSS still valid?

Yes. Every change made here is one the CSS specification treats as equivalent, so the browser parses it to exactly the same rules.

Why does it not merge duplicate rules?

Because the cascade depends on order. Two rules with the same selector can both be intentional, and merging them changes which declaration wins. Safe minification means byte-level changes, not structural ones.

How much smaller will my file get?

Typically twenty to thirty percent for a hand-written stylesheet with comments and indentation. Frameworks that were already compact save far less.

Is minifying worth it with gzip enabled?

Less than people expect, since compression already handles repeated whitespace well. The real saving comes from removing comments and unused rules, and the latter is a different job entirely.

Will shortening hex colours change my colours?

No. A three-digit hex is expanded by doubling each digit, so the shortening only happens when the full form has matching pairs and the two are genuinely identical.

Can I undo it?

Use the CSS Formatter to expand it again, though comments are gone for good.

If the css minifier is not quite what you need, these other free tools solve closely related problems.

CSS Formatter

Format CSS with consistent indentation, spacing and one declaration per line.

Code Formatters Use tool

HTML Minifier

Shrink HTML by removing comments and collapsing whitespace, safely.

Code Formatters Use tool

JavaScript Minifier

Shrink JavaScript by removing comments and whitespace, without renaming anything.

Code Formatters Use tool

Image Compressor

Compress and resize JPEG, PNG and WebP images privately in your browser.

Image Tools Use tool

CSS Gradient Generator

Design linear and radial gradients with live preview and copyable CSS.

Color Tools Use tool