CSS Minifier

Take the formatting out of a stylesheet, and see exactly how many bytes that removed.

Runs on your deviceDeveloperWorkingNo account needed

What this tool does

CSS Minifier walks the stylesheet one character at a time, dropping comments and every space, tab and newline that cannot change how a rule is read. It is conservative on purpose: nothing is renamed, no two selectors sharing a body are merged, no declaration is reordered, and nothing is deleted for being overridden further down the file. Combinators are tightened, so a > b loses its spaces, and the final semicolon of each block goes with them.

The scanner knows where it has to stop. Quoted strings are copied through untouched, so a content value keeps both its spacing and any text inside it that looks like a comment. Inside a bracket the rule relaxes: a space survives unless it follows an opening bracket or a colon, sits beside a comma, or comes just before the closing bracket — which is what leaves calc(100% - 24px) intact while (min-width: 600px) still loses the space after its colon. A space written before a colon is also kept, because that is exactly what separates the descendant selector p :first-child from a pseudo-class attached to p. Two checkboxes control the rest: licence comments, meaning any comment opening with an exclamation mark or a second asterisk, are preserved while that option is on, and the colour option shortens #aabbcc to #abc only where all three pairs repeat, leaving eight-digit hex with an alpha channel alone.

It is a scanner rather than a CSS parser, and that sets the boundary of what it can be trusted with. Nothing is validated: a stray brace or a misspelt property travels straight through, and an unclosed comment discards everything after it, because the scanner looks for the closing marker and reaches the end of the file instead. A url() is copied through rather than picked apart, although runs of whitespace inside it collapse to one and the spaces beside its brackets go; that protection stops at the first closing bracket, so a path carrying an unescaped bracket of its own hands the remainder of the value back to the ordinary rules. An unclosed bracket reaches further still, because the scanner then treats everything after it as bracket contents and keeps spaces it would otherwise remove. Check the result against a real page before you ship it.

The byte counter measures the file, not the transfer. Almost everything removed here — indentation, blank lines, comment blocks — is what gzip and brotli are already best at, so a stylesheet served compressed gains far less on the wire than the percentage suggests. The saving is real where the CSS is counted uncompressed: inside a style block in the document head, in an email, or against a bundle budget. All of it happens in this browser tab, so the stylesheet is not uploaded — though that also means there is no file picker and no .css download, only a box to paste into and a button to copy from.

How to use it

  1. Paste the stylesheet. The input is a text box rather than a file picker. Press Load sample to see a short stylesheet with a comment, a hover rule, a media query and a calc() in it.
  2. Decide what survives. Keeping licence comments and shortening six-digit colours are both on by default. Switch the colour option off if anything downstream matches full hex values literally.
  3. Read the size summary. The line under the output box reports the size before and after with the percentage removed. Both figures are real UTF-8 byte counts of the text in each box, shown in B or KB, so anything past a kilobyte is rounded for display.
  4. Copy the output. Copy output puts the minified stylesheet on the clipboard. Nothing is written to a file here, so it goes straight into a build asset, a template or a style block.

Processing & privacy

Runs on your device. Your file is processed directly in this browser.

Common use cases

Inlining critical CSS

Styles that go straight into the document head are counted inside the HTML byte budget, where indentation and developer comments are pure weight.

Sending an HTML email

Mail clients impose their own size ceilings and treat comments inconsistently, so the compact copy is the safer one to put in the message.

Shipping a theme or plugin stylesheet

Keep the readable source in the repository and ship a minified copy beside it. The header survives only if it opens /*! or /**, so a WordPress style.css block starting with a plain /* is dropped like any other comment.

Tidying CSS a generator produced

Exported rules from a design tool, a gradient builder or a shadow generator arrive loosely formatted and annotated for a reader who will never open the file.

Questions

Is my CSS uploaded anywhere?
No. The scanner runs in this browser tab, so the stylesheet is never transmitted or stored, and once the page has loaded it goes on working with the connection switched off.
Will it break my stylesheet?
It only takes out comments and whitespace that cannot change meaning: quoted strings come through byte for byte, a url() keeps its path, and the spaces that carry meaning inside brackets stay. What it cannot do is warn you about CSS that was already broken, because it does not parse or validate — a stray brace passes through, and an unclosed comment takes the remainder of the file with it.
Does it remove unused or duplicated rules?
No. Judging a rule unused needs the pages that load it, and this tool only ever sees the stylesheet you paste. Duplicate and overridden declarations are kept exactly as written, in your order.
Does it shorten values as well as colours?
Only the six-digit-to-three-digit hex case, and only when you leave that option on. Units are untouched, 0px stays 0px, shorthand is not rewritten and named colours are left as names.
Why is my saving smaller than I expected?
The percentage is measured on your own file, so it depends entirely on how that file was written. Output from a build step that already collapsed the indentation has little left to give, while a hand-formatted stylesheet full of block comments loses a great deal.
Should I do this instead of compressing on the server?
The other way round. Brotli or gzip on the response does more for transfer size than removing whitespace, and the two stack: compress CSS at the server, and minify where the bytes are counted before that happens.
Can I get the readable version back?
Not here. Removing formatting is one-way and this tool has no expand mode, so keep the source stylesheet and treat the minified text as a build output rather than the copy you edit.

Related tools