Skip to content
DeveloperRuns in your browser

CSS Minifier

Compress a stylesheet by removing comments and whitespace.

Input
No upload needed — instant
Privacy
Nothing is uploaded
Cost
Free · no sign-up · no watermark

Loading tool…

The tool is loading its code on your device. This happens once and is cached for later visits.

Processed entirely on your device

Everything you type or paste is handled by JavaScript running in this tab. No request is sent, nothing is logged and nothing is stored. Close the page and it is gone.

Overview

About the CSS Minifier

Minify CSS online — strip comments, whitespace and unnecessary characters from a stylesheet to reduce its size, and see the byte saving. Runs in your browser, no upload.

CSS is render-blocking: the browser will not paint the page until the stylesheet has downloaded and parsed. That makes it the one asset where minification has a direct, measurable effect on how fast a page appears, rather than just on how much bandwidth it uses.

What the minifier removes

Comments go first — they are notes for humans and are never part of the cascade. Then the whitespace that carries no meaning: the newlines between rules, the indentation inside a block, and the spaces around braces, semicolons and colons. A declaration written across four lines becomes one, and the whole sheet collapses to a single stream of rules.

What it must never touch

CSS uses whitespace as syntax in a few places, and this is where naive minifiers break stylesheets:

ContextWhy the space matters
div pThe space is the descendant combinator
content: "a b"Whitespace inside a string is literal
url(my file.png)Spaces inside a URL value are significant
a, bKeep the comma; the space beside it is optional

The rule the minifier follows is simple: collapse a run of whitespace to a single space where a space is meaningful, and delete it entirely where it is not. Getting that distinction right is the whole job.

What this tool deliberately does not do

A full CSS optimiser can also shorten hex colours, convert rgb values, strip units from zero lengths, merge duplicate rules and reorder declarations. Those transforms change the text of your CSS and occasionally change behaviour, so they belong in a configurable build step you can test against your real pages. This minifier does the safe, universal part — comments and whitespace — and leaves the rest alone.

Where it fits

Keep the readable, commented stylesheet in source control and minify during the build, so the file you ship is small and the file you maintain is legible. For a quick one-off — inlining critical CSS into a document head, or shrinking a snippet for an email — minifying by hand here is the fastest route.

Step by step

How to use the CSS Minifier

  1. Paste your stylesheet into the input panel.

  2. Press Minify CSS; comments and insignificant whitespace are removed.

  3. Check the before and after byte counts to see the saving.

  4. Copy the compressed CSS or download it as a .css file.

Why use it

Benefits and common use cases

What this tool is good for, and what it deliberately does not try to do.

Render-blocking bytes removed

Stylesheets block first paint, so every kilobyte you shave off is time the browser is not waiting. Minification is the cheapest win available on critical CSS.

Safe, structure-preserving pass

Selectors, properties and values are left exactly as written; only comments and whitespace that carry no meaning are removed, so specificity and cascade order never change.

Keeps strings and data URIs intact

Whitespace inside content strings, url() values and base64 data URIs is preserved, which naive find-and-replace minifiers get wrong.

Private and instant

The stylesheet is compressed in your tab, so proprietary styles and unreleased design tokens are never transmitted.

Questions

Frequently asked questions

Short, honest answers about quality, limits and privacy.

Does minifying CSS change how the page is styled?

No, provided the minifier is correct. Whitespace around most punctuation is insignificant in CSS, so removing it does not affect which rules apply. The exceptions are inside strings, inside url() values and the single space that separates descendant selectors, all of which must be preserved.

Why does the space in a selector matter?

A space is a combinator. The selector div p means a p inside a div, while divp would be a single unknown element. A correct minifier collapses runs of whitespace to one space where the space is meaningful and removes it entirely where it is not, such as around braces, colons and semicolons.

Are CSS comments removed?

Yes, both the block comments used for notes. They are never rendered, so dropping them is safe and is usually the single biggest saving on a heavily annotated stylesheet.

Does it shorten colours or drop units?

This tool is conservative and does not rewrite values such as colours to their short form or strip units from zero lengths. Those optimisations change the text of your declarations, which is best left to a full build-time optimiser you can configure and test.

How much smaller does CSS get?

Typically 20 to 35 percent for a readable, commented stylesheet, and more if it was heavily indented. As with HTML, transport compression reduces the marginal benefit, but minified plus compressed is still the smallest option.