Free CSS Minifier
Compress CSS code by removing comments, whitespace and optimizing values.
Why CSS Minification Still Matters in 2026
It's tempting to assume that because Brotli compresses text streams so aggressively, the marginal value of a separate minification pass has collapsed. The Sentry engineering blog ran exactly that argument in April 2024 and concluded the opposite: minification still pays. With global median mobile internet speed around 53 Mbps and Brotli universally deployed at the CDN edge, "if you can shave off just 1 KB from a total of 100 resources on each page load, you could be making a 15 ms improvement on your page speed for those users." Multiplied across the visitor base of any non-trivial site, that becomes a real bandwidth bill, a real battery cost on mobile devices, and a real position change on a Lighthouse report.
The mechanism matters. Gzip and Brotli are general-purpose lossless compressors that look for repeated byte sequences and encode each repetition as a back-reference into a sliding-window dictionary. Two CSS files that produce the same browser behaviour but contain different bytes will compress to two different sizes. margin: 10px 10px 10px 10px; and margin:10px are semantically identical, but the first has more characters that need encoding even though many are repeats, Brotli is good at finding repetition but does not understand that two syntactically distinct CSS strings express the same rule. Only a CSS-aware minifier can do that. Cloudflare's learning hub puts typical raw-text reductions at 30-50%; Brotli on top adds another modest 5-15%, but it is not zero, and at scale it adds up.
CSS Is Render-Blocking, and That's Why Bytes Count
Largest Contentful Paint is one of the three Core Web Vitals; the threshold for "Good" is 2.5 seconds at the 75th percentile of page loads. Lighthouse's overall Performance score weights LCP at 25% of the total. CSS is render-blocking by default, when the browser sees a <link rel="stylesheet"> it pauses rendering until that file is downloaded and the CSSOM is constructed, because rules later in the stylesheet can override earlier ones and the browser cannot risk painting in an unstyled or wrongly-styled state. The CSS Object Model, unlike the DOM, is not built incrementally, the parser needs the whole stylesheet to know which rules win. JavaScript also blocks on this: scripts cannot run safely while the CSSOM is incomplete. The practical implication is that every byte of render-blocking CSS sits on the critical path of every Core Web Vital. A 100 KB minified bundle saves you maybe 30 ms on a fast 4G link compared to a 150 KB unminified one, small per page, but Vodafone's case study showed an 8% sales increase from a 31% LCP improvement. The second-order effect is even larger: faster LCP raises Lighthouse scores, which raises Google search visibility for sites where Web Vitals are a known ranking signal.
What a CSS Minifier Actually Does
- Whitespace removal. Spaces, tabs and newlines that exist only for human readability are stripped. Whitespace inside strings (font-family names, content values, URLs) and whitespace that separates tokens stays,
1px solid redcannot become1pxsolidredbecause the parser would no longer recognise the three values. - Comment removal.
/* ... */blocks are deleted. The widely-honoured convention is that comments beginning with/*!are treated as important (usually copyright or license notices) and preserved by production minifiers like cssnano, clean-css, lightningcss and esbuild. - Zero-unit collapsing.
0px,0em,0%,0pt,0vwall reduce to0, because zero length is the same length regardless of the unit. The careful edge case (Miriam Suzanne's "Not All Zeros are Equal," 2022): zeros insidecalc(),min(),max()andclamp(), and inside CSS custom properties, cannot be safely stripped because the typed-arithmetic rules of CSS Values and Units Module Level 4 require a unit to disambiguate length from number.0sin atransitioncannot become0because the property requires a time value. - Hex colour shortening. A six-digit hex colour where each pair of digits is identical can be written as three digits:
#FFFFFF → #FFF,#336699 → #369. The CSS Color spec defines the three-digit form as exactly equivalent and has done since CSS1. - Trailing semicolon removal. The semicolon between the last declaration in a rule block and the closing brace is optional, so
color:red;}becomescolor:red}. One byte per rule, which adds up. - Keyword lowercasing. CSS keywords are case-insensitive, so
BLOCKandblockmean the same thing, but lowercase compresses better and tokenises uniformly. - Shorthand collapsing.
margin: 10px 10px 10px 10pxbecomesmargin: 10px;margin: 10px 20px 10px 20pxbecomesmargin: 10px 20px. Production minifiers know the shorthand rules formargin,padding,border,border-radius,background,font,transition,animationand the grid family.
Minifier vs Optimiser, The Safe-vs-Aggressive Line
cssnano's documentation distinguishes between its "default" preset (safe transforms only) and its "advanced" preset (aggressive transforms that depend on assumptions about your CSS). The default preset is what you turn on without thinking; the advanced preset is what you turn on after auditing, because some optimisations can break code that depends on subtle cascade behaviour, vendor prefixes, or browser quirks. Advanced transforms can re-order rules within a stylesheet to improve compressibility, risky if you have intentional duplicate-property fallbacks like display: flex; display: grid;. They can merge identical rule bodies into comma-separated selector lists. They can drop overridden declarations as dead code, with the same fallback caveat. They can normalise display values, transform functions and custom identifiers, translate3d(0,0,0) may simplify to translate(0) if you don't depend on the GPU-promotion side-effect. They can drop unused vendor prefixes based on a Browserslist target. csso (Yandex, 2011) describes itself as a "structural optimiser" rather than a pure minifier, with three transformation categories: cleaning, compression, and restructuring. Lightning CSS describes the same split: a "minify" pass that is always safe, plus a set of targets-aware transformations that compile modern CSS down to what older browsers understand. The honest line: a minifier is what you can apply to any CSS file with no thought; an optimiser is what you apply with knowledge of your codebase.
A Short History of CSS Minification Tooling
YUI Compressor (2007). Yahoo's Julien Lecomte announced YUI Compressor on 11 August 2007. The original release handled JavaScript only; three days later, version 2.0 added CSS support by integrating a regex-based CSS minifier originally written by Isaac Schlueter for personal use. YUI Compressor was the de facto standard for several years, especially in the Java/Maven and Rails-asset-pipeline worlds; it's still used today, though the YUI library itself was retired by Yahoo in 2014. The CSS side of YUI Compressor was always regex-based, not AST-based, a design decision whose consequences echo in the smaller browser-side tools that followed.
clean-css (2011). Jakub Pawlowicz published clean-css under the GoalSmashers organisation on GitHub in 2011, billing it as "fast and efficient CSS optimizer for Node.js and the Web." It was the first major CSS minifier designed specifically for the Node.js ecosystem and became the default in Grunt and Gulp pipelines. The current 5.x line pulls roughly 21 million weekly downloads from npm, supports @import inlining, URL rebasing and source maps, and has a tiered "optimisation level" model that makes the safe-vs-aggressive split explicit. csso (2011) originated as a Yandex internal project, published with copyright 2011 by Sergey Kryzhanovsky based on an idea from Vitaly Harisov. cssnano (April 2015) by Ben Briggs took a different approach: instead of one monolithic minifier, cssnano is a curated bundle of small PostCSS plugins (~30 in the default preset). It became the dominant CSS minifier in the JavaScript ecosystem largely because of this composability and because PostCSS itself (Andrey Sitnik's framework, first released November 2013) became the substrate for so much else (Autoprefixer, Stylelint, Tailwind's processing pipeline). cssnano now sits at version 7.x and is the default CSS minifier in webpack's css-minimizer-webpack-plugin, in Next.js, and in many other framework defaults.
esbuild's CSS minifier (2020-2021). Evan Wallace, the co-founder of Figma, released esbuild as "a hobby project that I wrote over the 2019-2020 winter break." Written in Go, esbuild was 10-100× faster than the JavaScript-based bundlers of the day. CSS support matured through 2021; it is now ubiquitous as the underlying minifier in Vite, in tsup, in countless framework templates. Lightning CSS (2021/2022). Devon Govett, creator of Parcel, announced Parcel CSS in 2021, a CSS parser, transformer, bundler and minifier written from scratch in Rust. The pitch was speed (10-100× faster than the JS-based incumbents) plus correctness (a real CSS-spec-following parser, not regex pattern-matching) plus targets-aware compilation (lower modern CSS to what older browsers understand, like Babel for JavaScript). In 2022 the project was renamed Lightning CSS to dissociate it from Parcel as a standalone tool. It is now Vite's recommended modern CSS pipeline, the default in Parcel itself, and an option in css-minimizer-webpack-plugin. Tailwind's next-generation Oxide engine integrates it.
The Modern CSS Pipeline
Modern web projects rarely write raw CSS into a stylesheet. Sass (Hampton Catlin and Natalie Weizenbaum, first released 2006), Less (Alexis Sellier, 2009) and Stylus (TJ Holowaychuk, 2010) sit at the front of the pipeline, adding variables, nesting, mixins, functions and partials. The compiler emits vanilla CSS, which then flows through PostCSS for transforms like Autoprefixer (vendor-prefix application based on Browserslist), nested-CSS unwrapping and modern CSS down-levelling. Only after all this does the minifier run, on the final flat CSS. Modern bundlers ship CSS minification by default, webpack 5 includes css-minimizer-webpack-plugin (cssnano under the hood by default, with cssoMinify, cleanCssMinify, esbuildMinify and lightningCssMinify all selectable); Vite uses esbuild for CSS by default and supports Lightning CSS as opt-in; Parcel uses Lightning CSS; Next.js, Remix, Astro, SvelteKit and Nuxt all bundle minification into production builds without developer intervention. The result is that for anyone using a modern build pipeline, CSS minification happens automatically.
But not everyone uses a build pipeline. Plenty of WordPress sites, hand-rolled HTML pages, Jekyll/Hugo/Eleventy static sites without a JS toolchain, and one-off projects ship CSS that has never been near webpack. For those, an in-browser minifier is the path of least resistance, paste the CSS in, copy the result out, save the deployment.
Critical CSS
A complementary technique worth knowing about: critical CSS is the practice of identifying the subset of styles needed to render the above-the-fold viewport, inlining that subset directly into a <style> block in the document head, and deferring the rest of the stylesheet to a non-blocking load. Done well, the page paints its initial viewport on the very first network round trip, with no separate request for an external stylesheet at all. Filament Group built the canonical tooling, Scott Jehl published loadCSS on 14 July 2014, a small JavaScript utility that loads a stylesheet asynchronously by setting its media attribute to a non-matching value, then swapping it back to all once the file has downloaded. The pattern eventually became standard enough that browsers added <link rel="preload" as="style" onload="this.rel='stylesheet'"> as a more direct way to express it. Jason Miller (creator of Preact) released Critters under GoogleChromeLabs in 2018 as a faster alternative, instead of running a headless browser to inspect the rendered page, Critters does static analysis. The Critters repository was archived in 2024 with the actively-maintained fork now living as Beasties under the Nuxt team. All these tools depend on the underlying CSS being well-minified, every byte saved in the source stylesheet flows through to a smaller critical inline.
The Legacy Hacks Are Gone
Modern browsers all parse CSS to the same spec. The historical hacks that once made CSS minification risky are essentially gone: the * html hack targeted IE6 by exploiting a parser bug; the underscore hack _property: value targeted IE6 and below; *property: value (with * before the property name) targeted IE7 and below; conditional comments <!--[if IE 6]> let you serve different stylesheets to specific IE versions, but Microsoft removed this feature in IE10. IE11 reached end-of-life on 15 June 2022 for most consumer Windows 10 versions. As of 2026 these hacks are historical curiosities and a CSS minifier no longer needs to think about them. A modern minifier that strips whitespace identically across browsers and applies the spec-defined transformations described above is safe.
What This Tool Does (and Doesn't)
This tool is a single-file in-browser minifier, roughly 30 lines of JavaScript. It tokenises string literals into placeholders so subsequent passes cannot corrupt their contents, removes /* ... */ comments, collapses whitespace around {, }, :, ;, ,, >, ~, +, removes the trailing semicolon before }, collapses runs of whitespace to a single space, shortens six-digit hex colours to three-digit form when each pair of digits is identical, and strips the unit from zero values for px, em, rem, %, pt, ex, ch, vw, vh, vmin, vmax. It does not parse the CSS into an AST, it is a regex pass. It does not collapse longhand to shorthand. It does not merge or de-duplicate selectors. It does not re-order declarations. It does not convert rgb() to hex or named colours to hex. It does not lowercase keywords. It does not preserve /*! important comments, all comments are stripped equally; if you have license headers to keep, paste them back in after minification. It does not emit a source map. The honest framing: paste the CSS that came out of your editor or your hand, get back a stripped version that is typically 20-40% smaller in raw bytes, and use it as a quick-deploy artifact for hand-built sites. For projects with a build pipeline, use cssnano or Lightning CSS in that pipeline; for those that don't, this tool removes the friction.
Why Browser-Only Matters Here
Every web-based CSS minifier has the same architectural choice: do the work on a server, or do it in the user's browser. Server-side processing requires uploading the stylesheet over the network, which means a copy of that CSS sits in the server's logs, possibly in a CDN cache, possibly in an analytics pipeline, possibly in a backup. For most CSS this is harmless. For internal tools, unreleased product styles, or stylesheets that contain selectors revealing internal class taxonomies (.admin-panel-internal-debug-info), it is not. Even for ordinary marketing-site CSS, a developer auditing what they actually send across the network may reasonably prefer that work-in-progress stays on their machine. A purely browser-based minifier (JavaScript that runs in your tab and never makes a network request after the initial page load) sidesteps the issue. You can verify this: open DevTools' Network tab, paste the CSS, click Minify, and watch for any outgoing request. There won't be one. Better yet, disconnect from the internet (or enable airplane mode) after the page loads and the tool will still work, which is the strongest empirical proof that nothing is being uploaded.
Frequently Asked Questions
How much smaller will my CSS be?
Hand-formatted CSS with comments and indentation typically shrinks 20-40% in raw bytes. CSS that has already been compiled from Sass/Less and lightly formatted shrinks less. CSS that has been processed through PostCSS or Autoprefixer often already has minimal comments and shrinks the least. The size after Brotli compression at the CDN edge will narrow further, Brotli on minified CSS still saves another 5-15% over Brotli on unminified CSS, depending on how repetitive the original whitespace was.
Will the minified output break anything?
For ordinary CSS, no, the transformations are spec-safe. The two cases worth checking yourself: (1) zero values inside calc(), min(), max(), clamp() and CSS custom properties should not be unit-stripped because the typed-arithmetic rules require a unit; this tool's regex pass is conservative but if you have calc(0px + 10%) in your CSS, eyeball the output. (2) If your stylesheet has duplicate-property fallbacks like display: flex; display: grid;, this tool preserves both, but advanced minifiers like cssnano with the advanced preset would remove the first one. If you depend on browser-specific cascade behaviour, audit before deploying.
Does it preserve license headers?
No. Production minifiers honour the convention that comments beginning with /*! (with an exclamation mark) are preserved as "important", usually for copyright headers and license notices. This tool strips all comments equally. If you ship CSS that needs a license header (MIT, GPL, BSD source attribution), paste the header back into the output manually. For a pipeline that needs automatic preservation, use cssnano or Lightning CSS instead.
Should I use this if I already have a build pipeline?
Probably not, your bundler is doing this for you. webpack 5 ships css-minimizer-webpack-plugin with cssnano under the hood; Vite uses esbuild for CSS minification by default; Parcel uses Lightning CSS. This tool is for the cases your build pipeline doesn't cover: hand-rolled HTML, WordPress themes shipped without a Node toolchain, static-site generators that don't bundle minification, one-off CSS files for an email template or a quick demo. For those, a paste-in browser tool is the path of least resistance.
Are my files uploaded?
No. The minifier is JavaScript running in your browser. The CSS you paste never crosses the network, verify in DevTools' Network tab while you click Minify, or take the page offline after it loads and confirm the tool still works. Internal stylesheets, unreleased product styles and CSS revealing internal class taxonomies stay on your device.
Can I unminify the output later?
Not exactly, comments and original whitespace are gone forever, that's the point. But you can format minified CSS to make it readable again. Pretty-printers like Prettier (with the CSS plugin), the built-in Format Document command in VS Code, or any of the online "CSS beautifier" tools will reinsert indentation and line breaks. They cannot recover deleted comments. Always keep your unminified source in version control as the canonical form.