CSS Minifier
Take the formatting out of a stylesheet, and see exactly how many bytes that removed.
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
- 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.
- 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.
- 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.
- 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?
Will it break my stylesheet?
Does it remove unused or duplicated rules?
Does it shorten values as well as colours?
Why is my saving smaller than I expected?
Should I do this instead of compressing on the server?
Can I get the readable version back?
Related tools
- JSON Formatter — Pretty-print, collapse and inspect JSON instantly.
- Base64 Encoder Decoder — Encode and decode Base64 text and files.
- JWT Decoder — Inspect the header, payload and claims of a JWT.
- Hash Generator — Compute MD5, SHA-1, SHA-256 and SHA-512 digests.
- Regex Tester — Test patterns against sample text with live matches.
- Unix Timestamp Converter — Convert between epoch seconds and readable dates.