CSS Compressor - Compress CSS Online
Compress CSS online and see how many bytes you save: comments and spare whitespace go, while strings, url() paths, calc() and custom properties stay exactly as written.
How to Compress CSS - Step by Step Guide
Input Your CSS Code
Ready to optimize your CSS? You have several convenient options to get started:
Example: Uncompressed CSS Input
Here's what typical, unoptimized CSS looks like:
/* Navigation Styles */ .navbar { background-color: #2c3e50; padding: 1rem 2rem; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); } /* Button Styles */ .btn-primary { background-color: #3498db; color: white; border: none; padding: 0.75rem 1.5rem; border-radius: 4px; }
Automatic CSS Compression
The output updates as you type. To make the file smaller, the compressor:
Example: Compressed CSS Output
The same CSS after compression, exactly as the tool writes it:
.navbar{background-color:#2c3e50;padding:1rem 2rem;box-shadow:0 2px 4px rgba(0,0,0,0.1)}.btn-primary{background-color:#3498db;color:white;border:none;padding:0.75rem 1.5rem;border-radius:4px}
View Compression Results
The badge above the output tells you what you saved on this file:
Export Your Compressed CSS
When the size looks right, take the result with you:
What is CSS Compression? ⚡
CSS compression is the process of reducing CSS file size by removing unnecessary characters like whitespace, comments, and redundant code without affecting functionality. This optimization technique significantly improves website loading speed and reduces bandwidth usage.
Compressed CSS files load faster, consume less server resources, and provide better user experience, especially on mobile devices and slower internet connections. If you want the rules explained in more detail, the CSS Minifier page runs the same engine.
Frequently Asked Questions
How many bytes will compressing my CSS save?
That depends entirely on how the file was written. Comments, deep indentation and blank lines are what get removed, so a well-documented stylesheet drops a lot and an already tight one hardly moves. The badge above the output shows the size in bytes before and after, plus the percentage, for the exact file you pasted. The example on this page goes from 278 to 191 bytes, roughly 31% less.
Will the compressed file look different in the browser?
It should not. Only comments and whitespace between tokens are taken out. Anything inside quotes, url() paths, escaped characters and custom property values are copied exactly. Spaces that CSS depends on stay, for example around + and - inside calc() and before "and (" in a media query. Numbers keep their spelling too, so 0.75rem is not shortened to .75rem and colors are not rewritten.
Does this replace gzip or Brotli on my server?
No, the two work together. This page makes the file itself smaller; gzip or Brotli then compress it again while it travels to the visitor. Removing comments and whitespace first still helps, because the browser has less text to download, decompress and parse.
Is my license comment kept?
Yes, if it starts with /*! - that is the common way to mark a copyright or license notice that has to stay in the shipped file. Every other comment is dropped.
Is this the same as the CSS Minifier?
It is the same engine. People search for both words, so both pages exist; the CSS Minifier page explains the rules in a bit more detail. Pick whichever you have bookmarked.
Is my stylesheet sent to a server?
No. Compression happens in your browser, so the CSS you paste or upload stays on your computer. It is free and you do not need an account.
Related Tools
CSS Minifier
Minify and compress CSS code
CSS Beautifier
Beautify and format CSS code
CSS Formatter
Format and organize CSS code
CSS Fixer
Fix broken CSS automatically, repair syntax errors, missing semicolons, and malformed styles
CSS Autoprefixer
Automatically add vendor prefixes for cross-browser compatibility
CSS Validator
Validate CSS syntax and detect errors in your stylesheets