Minify CSS: What It Is, How to Check It and How to Fix It
What minifying CSS does, how our report decides a stylesheet is minified, and the quickest ways to fix unminified files.
Free to use 7 min read Updated Oct 2026
What Does It Mean to Minify CSS? The Quick Answer
Quick answer: To minify CSS is to strip whitespace, comments and redundant characters from a stylesheet, so the browser downloads fewer bytes and reads the same rules. Our report wants every stylesheet it fetches to look minified.
- Pass: every stylesheet we fetched averages more than 200 characters per line.
- Fail: some files look minified and some don't (Warning), or none do or the page links no stylesheet (Failed).
- Fix: serve .min.css files from your build or a plugin, and keep the readable source.
The gain is real if modest: Bootstrap 5.3.3 shrinks about 17 percent. To shrink a file now, use our free CSS Minifier.
What CSS Minification Removes and What It Leaves Alone
Basic minifiers remove comments (except license banners), line breaks, indentation, the spaces around braces and colons, and the last semicolon. Better ones such as CSSO also shorten colors, turn 0px into 0 and merge duplicate rules. The page must render identically, so any difference is a bug.
Before and after on a small rule
/* Before */
/* Page heading */
h1 {
color: #ffffff;
margin: 0px auto;
}
/* After */
h1{color:#fff;margin:0 auto}Minify, compress, purge
Minifying rewrites the file so it is shorter, while gzip or Brotli encode it for the trip, so you want both (see gzip compression). Neither removes unused CSS; that takes a purge tool such as PurgeCSS.
Why Minify CSS? What You Actually Gain
Each readable file was compared with its official .min.css, raw and with gzip level 6.
| File | Original bytes | Minified bytes | Saved |
|---|---|---|---|
| Bootstrap 5.3.3, raw | 281,046 | 232,803 | 17.2 percent |
| Bootstrap 5.3.3, gzip | 33,478 | 31,118 | 7.0 percent |
| animate.css 4.1.1, raw | 95,374 | 71,750 | 24.8 percent |
| animate.css 4.1.1, gzip | 5,947 | 5,270 | 11.4 percent |
The saving is a small, cheap win, not a cure for a slow site. It still matters because CSS blocks rendering until it is parsed, as render blocking resources explains.
In our samples animate.css lost a quarter of its raw size and Bootstrap a sixth, so indented framework and theme files gain most. The Lighthouse Minify CSS audit estimates savings by counting only comments and whitespace, so a full minifier can save more.
How SEO Site Checker Tests CSS Minification
The rule: we download each linked stylesheet and divide its characters by its lines. More than 200 per line is minified. At 200 or below it counts as unminified CSS.
What the check reads
The scan renders your page in headless Chromium and collects the stylesheet link tags, checking only the first 8. Each file gets 3 seconds, and the whole batch stops after about 10 seconds, so a slow server can leave files unchecked. Any file we can't download in time counts as unminified, which can drag a clean site down to a Warning. Inline style tags and attributes are ignored.
How one file is judged
Bootstrap 5.3.3 source has 12,057 lines averaging 22.3 characters, so it is flagged. Its minified twin is 6 lines averaging 38,799 and passes, as do animate.min.css at 10,249 and Font Awesome's all.min.css at 11,404.
Passed, warning and failed
| Status | Condition |
|---|---|
| Passed | At least one stylesheet was fetched and none of the checked files is unminified |
| Warning | At least one file looks minified and at least one does not |
| Failed | No file looks minified, every fetch failed, or the page has no linked stylesheet |
The report prints how many files it checked, plus minified and unminified lists whose URLs show for signed in users.
Known blind spots
The rule measures average line length, not minification, so it can misjudge. Output that keeps one rule per line averaged 87.8 in our test and was flagged, as is a file under 200 characters.
Fetching has traps too, and each ends with the file counted as unminified. A URL starting with // fails in our fetcher, a limit of our tool, not a fault in your page, so use full https:// addresses. A relative path such as css/site.css on a page at /blog/post/ is requested from the site root and may return a 404, and because we don't check the HTTP status, that error page is scored as if it were CSS.
The check doesn't judge whether the output is correct, how much CSS is unused, or style tags and attributes, including ones added by scripts. Stylesheets pulled in by an @import rule are not followed either. One scan also feeds the CSS caching and media query check results.
How to Check Whether a CSS File Is Minified
- Open the file. A minified file is a dense wall of text.
- Compare sizes. In the Chrome DevTools Network tab, turn on Use large request rows, then read the second (lower) number in the Size column, the uncompressed resource size.
- Run the report. Run the free SEO report and sign in to see which files landed in each list.
- Measure it. Print the average line length below. Above 200 passes.
curl -sL https://example.com/css/style.css | awk '{ n += length($0) } END { print n / NR }'How to Minify CSS Files Step by Step
- Protect the source. Minifying runs one way, so keep the readable file in version control and never hand edit minified output.
- Small sites. Paste the CSS into our CSS Minifier and save the result as style.min.css.
- Projects with a build. Use cssnano through PostCSS, or clean-css or Lightning CSS from an npm script. See the cssnano documentation for options.
- Bundlers. Vite minifies CSS in production builds by default. webpack's production mode doesn't, so add css-minimizer-webpack-plugin.
- Point the link tag. Reference the .min.css file with a version query.
- Verify. Clear caches, compare the page with the old version, then re-run the report.
For PostCSS, save this config, then install and run it.
// postcss.config.js
module.exports = { plugins: [require('cssnano')] };npm install postcss postcss-cli cssnano
npx postcss style.css -o style.min.cssWithout PostCSS, clean-css needs one command.
npx clean-css-cli -o style.min.css style.cssHow to Minify CSS in WordPress and Hosted Platforms
For WordPress, install the Autoptimize plugin for WordPress, open its JS, CSS and HTML tab, tick Optimize CSS Code? and save. Caching plugins such as WP Rocket and LiteSpeed Cache have a Minify CSS switch too, though many plugins skip any file named .min, even a readable one. Clear every cache, then re-test.
| Platform | What to do | Watch out for |
|---|---|---|
| Shopify | Upload style.min.css to theme assets and load it with asset_url. | A stock Dawn base.css averages about 21 characters per line. |
| Wix | Minify only the CSS you add yourself. | You can't edit the platform's own files. |
| Cloudflare | Minify in your build or plugin. | Cloudflare has retired Auto Minify. |
Third party stylesheets such as a Google Fonts link or a widget's CSS follow the same rule. A Google Fonts stylesheet measured about 31 characters per line when we tried it, so it counts as unminified and you can't change it. Accept that Warning, or self-host the font.
Common Mistakes When You Minify CSS
Watch for: editing only the readable file and forgetting to rebuild, so the live link still points at the old stylesheet.
- Stale caches. A plugin or CDN keeps serving last week's style.min.css, so the report never changes. Purge every layer.
- One giant file. A single stylesheet holding every page's rules still blocks rendering, so split critical rules from the rest.
- Broken layout. Invalid source CSS can fail once whitespace is gone, and an old minifier may squeeze the spaces inside calc(), where CSS requires them.
Scripts share these traps, as our JavaScript minification guide shows.
How to Fix
The short version, the same steps you see when you click How to Fix in your report.
Why this fails: at least one stylesheet your page links to still has readable, indented lines with comments, or the file could not be fetched, so our check could not mark it as minified. The report measures the average line length of up to 8 linked stylesheets. An average above 200 characters per line counts as minified.
How to fix it:
- Find your stylesheets in the unminified list (shown when signed in) or the page source.
- Minify each one with our free CSS Minifier, or run cssnano, clean-css or Lightning CSS in your build.
- Save the result as style.min.css and keep the readable file as source.
- Point the link tag in your head at the minified file, using a full https:// address, not one starting with //.
- Swap third party files for their .min version, or drop tags you don't need.
- Make sure each file loads within about 3 seconds, because a timeout counts as unminified. A page with only inline style tags has nothing for the check to measure, so it will show Failed even though there is nothing to minify. Moving that CSS to an external minified file will clear the flag.
<link rel="stylesheet" href="https://example.com/css/style.min.css?v=2">For example, with clean-css:
npx clean-css-cli -o style.min.css style.css- WordPress: tick Optimize CSS Code? in Autoptimize, or enable minify CSS in your caching plugin, then clear the cache.
- Shopify and Wix: some theme CSS ships readable and gets flagged. If the report lists files you can't edit, accept the Warning for those and minify only the CSS you add yourself.
- Cloudflare: minify in your build or plugin, because Auto Minify has been retired.
To measure a file, print its average line length. An average above 200 characters per line passes.
curl -s https://example.com/css/style.min.css | awk '{ n += length($0) } END { print n / NR }'Re-test: confirm the number is above 200, then run our free SEO report again and look for Passed on CSS Minification.
Frequently Asked Questions
How do I minify a CSS file?
How do I minify CSS in WordPress?
What is CSS minification?
Does minifying CSS improve performance?
Is minifying the same as compressing CSS?
Can you reverse minified CSS?
Are there downsides to minifying CSS?
Does Vite minify CSS?
See how your site scores right now
Paste your address into the free report, then use the How to Fix button on anything that needs work.
Free to use. Results in under a minute for most sites.