CSS minifier

Minify your CSS by removing all the unnecessary characters.

Rated 5 out of 5 (total ratings: 1)
CSS minifier

CSS minifier is a free tool that removes unnecessary characters from CSS and returns a more compact stylesheet with before-and-after character counts.

Why minify CSS before a release?

Minifying CSS reduces the amount of stylesheet data that a browser needs to download and parse. The operation commonly removes formatting whitespace, line breaks, indentation, and other characters that are unnecessary for the browser to interpret the rules.

CSS minification is usually a stylesheet deployment step. Keep the readable CSS source in version control, run the CSS minifier during a build or release process, and publish the compact stylesheet. This preserves useful CSS formatting for debugging while reducing the production stylesheet.

Minification and HTTP compression solve different problems. Minification changes the CSS source itself, while gzip or Brotli compresses the transferred bytes. Production sites commonly use both for stylesheet delivery.

There is little value in minifying CSS that is already compact. Prettifying CSS only a machine will read is also unnecessary. If you received a minified third-party stylesheet and need to inspect it, use a formatter or browser developer tools rather than minifying it again.

From editable source to compact output

Paste the stylesheet into the CSS field and run the operation. The work is done on the server. Your input travels to the server over HTTPS and is not stored.

The practical workflow is:

  1. Start with the readable source file rather than an existing minified copy.
  2. Save or commit that source before creating a production version.
  3. Paste the CSS into the tool and generate the compact form.
  4. Copy the Minified CSS result into a separate production file.
  5. Load the relevant pages and check layout, responsive breakpoints, fonts, images, and interactive states.
The CSS minifier tool on biolink.page, showing its input form

A small example begins with readable CSS such as .notice { color: #8a2100; padding: 12px 18px; }. A typical compact form is .notice{color:#8a2100;padding:12px 18px}.

Another input might be @media (max-width: 640px) { .menu { display: none; } }. Its compact representation can be written as @media (max-width:640px){.menu{display:none}}. Exact choices for optimizing CSS syntax can vary among minifiers, so compare behavior in a browser instead of expecting every implementation to produce identical text.

How much smaller did the stylesheet become?

Compare CSS characters with Minified CSS characters to see the reduction in character count. Subtract the second value from the first to find how many characters were removed.

These values are character counts, not network transfer sizes. The tool uses a multibyte-aware length function, so the count should not be treated as a byte total when the CSS contains accented or non-Latin characters. UTF-8 characters can occupy more than one byte, and gzip or Brotli will change the transferred size again.

A stylesheet's character reduction also does not predict its page-load improvement by itself. Browser caching, request overhead, compression, connection conditions, and the size of other assets all affect stylesheet delivery. For release decisions about CSS, inspect the actual file size and compressed transfer size in browser developer tools or your build report.

Example result produced by the CSS minifier tool

Which CSS problems should you check separately?

Use a CSS validator or browser parser to find syntax problems because this tool does not return a dedicated validation report. A compact stylesheet is not proof that a browser can parse its CSS successfully or that every CSS declaration will work as intended.

Common issues to check include:

  • A missing closing brace that causes later rules to be parsed in the wrong block.
  • An unterminated comment or quoted value.
  • A misspelled property name or an invalid property value.
  • Malformed selectors, media queries, or at-rules.
  • Relative asset URLs that stop resolving after the output file is moved to another directory.

CSS minification also cannot detect visual regressions caused by stylesheet rules. A declaration can be valid CSS and still hide content, override a component unexpectedly, or fail at a breakpoint. Check the browser console and the Styles and Network panels after replacing the original asset.

Awkward input and safe boundaries

Whitespace is often disposable in CSS, but some spaces carry meaning. Descendant selectors use whitespace, quoted values can contain spaces, and addition or subtraction inside calc() requires spacing under CSS grammar. A conforming minification operation must preserve characters needed to maintain those meanings.

Punctuation inside quoted strings, URLs, attribute selectors, and generated content also belongs to the value. Accented and non-Latin characters are permitted in CSS identifiers under applicable escaping and encoding rules. If a deployment pipeline changes encodings, verify those selectors and values in the final served file.

Numbers are ordinary CSS tokens, but units and signs matter. For example, 0, 0px, -0.5rem, and 50% do not all have interchangeable syntax in every context. Minification should preserve behavior rather than make speculative design changes.

Empty CSS input contains no stylesheet rules to minify. Very large stylesheets may also be better handled by a local build tool, where repeatable configuration, source maps, and automated testing can be managed as part of the project. If a release includes matching markup and scripts, the HTML minifier and JS minifier can handle those asset types separately.

Frequently asked questions

Can I paste SCSS or Less into a CSS minifier?

No. Compile SCSS or Less into standard CSS first, then minify the compiled output. Preprocessor variables, mixins, and other source syntax may not be valid CSS even when they resemble newer CSS features.

Will a new minified file invalidate browser caches?

Only if the asset URL or cache validation data changes appropriately. Production pipelines commonly use a content hash in the filename or update a versioned query parameter so browsers request the revised file instead of reusing an older cached response.

Is CSS with data URLs safe to minify?

Data URLs are valid inside CSS, but they can contain dense punctuation, encoded bytes, or quoted content. Test rules containing embedded SVG, fonts, or images after minification, especially if another build step also rewrites URLs.

Can the minified output go directly into an HTML style attribute?

Usually not if the input is a full stylesheet. A style attribute accepts a declaration list such as color:red;padding:4px, while a stylesheet can contain selectors, braces, media queries, and other constructs. Use the output in a CSS file or a style element when it contains complete rules.

Should vendor files be minified again?

Check the filename and contents first. Files ending in .min.css are commonly already minified, and processing them again may produce little or no useful reduction. Keep the vendor license and distribution requirements in mind before modifying third-party assets.

Before deployment, retain the readable source, compare the character counts, validate the CSS separately, and test the exact production file from the URL where browsers will load it.

Similar tools

HTML minifier

Minify your HTML by removing all the unnecessary characters.

111
1
JS minifier

Minify your JS by removing all the unnecessary characters.

107
1

Popular tools