How to use the CSS Minifier tool
- Add your stylesheetPaste the CSS, or choose “Open file” to load a .css file from your computer.
- Set preferencesDecide whether values get shortened, empty rules are dropped and /*! licence */ comments survive.
- Check the savingsCompressed CSS appears straight away alongside the original, minified and gzip sizes.
- 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
contentvalues; url()values and data URIs;- custom properties (
--variables) and spacing insidecalc(); - 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.