CSS Minifier: Compress and Minify CSS Code Online

Shrink stylesheets by stripping comments, spacing and characters browsers don’t need. This online CSS minifier also shortens colours and numbers safely, shows the exact bytes saved and lets you download the result.

  • Safe value shortening
  • Gzip size estimate
  • Runs in your browser
–Original
–Minified
–Saved
–Minified + gzip

How to use the CSS Minifier tool

  1. Add your stylesheetPaste the CSS, or choose “Open file” to load a .css file from your computer.
  2. Set preferencesDecide whether values get shortened, empty rules are dropped and /*! licence */ comments survive.
  3. Check the savingsCompressed CSS appears straight away alongside the original, minified and gzip sizes.
  4. Use the outputCopy it, or save it as a .min.css file ready for your site.

CSS minifier features

  • Comments and spacing removedIndentation, line breaks and developer notes that browsers ignore are deleted.
  • Safer value shorteningTurns 0.50em into .5em, 0px into 0 and #ffffff into #fff without touching selectors, strings or custom properties.
  • Important parts preservedQuoted strings, url() values, calc() expressions and licence comments are left exactly as they were.
  • Empty rules droppedSelectors with no declarations disappear, including those inside media queries.
  • Real-world savingsCompare sizes before and after, including the gzip figure your server will actually send.

Why minify CSS?

Stylesheets block rendering: a browser can’t paint the page until it has fetched and parsed them. Lighter CSS arrives and parses sooner, improving First Contentful Paint and Largest Contentful Paint, two measurements that shape user experience and Google’s Core Web Vitals. Hand-written stylesheets usually shrink by 20–40% after minification.

A before-and-after example

Original:

.banner {
    border : 0px none ;
    background : #000000 ;
    margin: 0.75rem 2.0rem;
}

Minified:

.banner{border:0 none;background:#000;margin:.75rem 2rem}

What the minifier changes and leaves alone

It changes:

  • comments, apart from those beginning /*!;
  • indentation, line breaks and doubled spaces;
  • the final semicolon in each block;
  • unnecessary leading and trailing zeros and units on zero values;
  • six-digit hex colours that have a three-digit equivalent.

It never changes:

  • selectors, including spaces that alter their meaning, such as a :hover;
  • text inside quotation marks, for example content values;
  • url() values and data URIs;
  • custom properties (--variables) and spacing inside calc();
  • the order of your rules.

Minification plus server compression

Minifying and compressing complement each other: Gzip or Brotli on your server cut the transfer size much further, which is why the gzipped size is shown as well. Keep your readable stylesheet for editing and serve the minified copy in production. Build tools such as Vite, webpack and Laravel Mix can minify automatically, so this tool is ideal for quick tasks, WordPress themes and static sites.

Finish the job by compressing markup with the HTML Minifier and scripts with the JavaScript Minifier.

Frequently asked questions

What does a CSS minifier do?
It removes comments, spaces and line breaks and shortens values, so the file gets smaller while the page looks exactly the same.
Is minified CSS safe to use?
Yes. Only changes that don’t affect rendering are made. Keep your original file for future editing.
How much smaller does CSS get?
Typically 20–40% for hand-written stylesheets. The tool shows the precise saving and the gzip size.
Are licence comments kept?
Yes. Comments beginning with /*! are preserved by default, the usual convention for licences.
Does my CSS get uploaded?
No. Minification runs in your browser and your code stays on your device.