CSS compressor
Paste your stylesheet, pick a compression level and get a smaller file back. Everything happens in your own browser, so your code never leaves your computer.
- Three levels, from readable to maximum
- Strings, url() and calc() stay intact
- Shows the gzip size too
What this CSS compressor does
A CSS compressor — also called a minifier — rewrites your stylesheet so the browser has to download fewer bytes, without changing a single thing about how the page looks. Indentation, line breaks and comments are there for you, not for the browser. Strip them and a typical hand-written stylesheet gets 15 to 35 percent smaller.
The three levels do progressively more:
Light · keep it readable
Comments and redundant whitespace go, but every rule keeps its own line and its indentation. Values are left exactly as you wrote them. Use this when the file still has to be readable for a colleague, or when you want to see what the tool considers redundant.
Standard · recommended
Everything goes onto one line, the last semicolon before each closing brace is dropped, and values are tidied up: #FFFFFF becomes #fff, 0.50em becomes .5em, 0px becomes 0, and the space in front of !important disappears. Comments marked /*! … */ are kept, so licence headers survive.
Maximum · strip everything
As standard, plus licence comments and empty rules are removed as well. This is the smallest result and the one to use for a production build you are not going to read again.
What it deliberately leaves alone
Most of the damage a naive minifier does comes from treating CSS as plain text. This one parses it instead, which is why the following survive:
- Text inside strings.
content: "a, b: c"keeps its comma, its colon and its spaces. A regular-expression minifier turns this intocontent:"a,b:c"and quietly changes what your page shows. - Data URIs.
url(data:image/svg+xml;charset=utf8,…)contains semicolons and commas that would otherwise be read as the end of a declaration. - Descendant selectors with pseudo-classes.
a :hoveranda:hovermean different things. Removing that space breaks the first one. - calc() arithmetic. The spaces around
+and-insidecalc()are required by the spec, andcalc(100% - 0px)breaks if the unit is stripped. - grid-template-areas. The quoted row strings keep their spacing, so your grid keeps its shape.
- Custom properties. A
--my-varvalue is a raw token stream and is passed through untouched; its name stays case-sensitive.
Your code stays on your computer
The compression runs in JavaScript in your own browser. Nothing is sent to a server, nothing is logged and nothing is stored, which matters if the stylesheet belongs to a client or to an unreleased project. You can check it yourself: open your browser's network tab and compress something — no request goes out.
If JavaScript is switched off the form falls back to a server-side version of exactly the same engine, so the tool keeps working. In that case your code does travel to the server for one request and is not stored.
Is minified CSS slower for the browser to read?
No. The browser parses the same rules either way; it just has fewer bytes to download first. The parsing work is identical.
Do I still need this if my server uses gzip or brotli?
Yes, though the gain is smaller. Compression algorithms are good at repeated whitespace, so gzip already removes much of the cost of indentation. Minifying first still typically wins another 5 to 12 percent on top of gzip, because shorter values and removed comments give the algorithm less to work with. Use both; they are not alternatives.
Can I get my original formatting back?
The formatting itself is gone, but the CSS beautifier turns minified CSS back into indented, readable code. Comments that were stripped cannot come back, so keep your source file.
Is there a file size limit?
No fixed limit. Because the work happens in your browser, the only ceiling is your own memory. Stylesheets of a few megabytes are fine; very large files simply take a moment longer.
Does it support modern CSS?
Yes. Nesting, @layer, @container, @supports, custom properties and @keyframes are all parsed as blocks rather than guessed at with patterns, so newer syntax passes through correctly.
Other tools on this site
Read more
- What is CSS minification? – What a minifier removes and what it saves
- CSS optimization for speed – Beyond minification: critical CSS and Core Web Vitals
- What breaks a CSS minifier? – Live test of the constructs minifiers get wrong
- Minifying CSS in WordPress – Which plugin does what, and when it breaks
- Frequently asked questions – Answers to the questions we get most
- Useful links – Reference material on CSS and speed
- About this site – Who makes this and how to reach us