Free Converter

CSS Minifier

Minify and compress CSS stylesheets instantly in your browser. Remove comments, collapse whitespace, and reduce file size. Free and private.

Drag & Drop a CSS file here

Supports .css files. Or paste your CSS above.

Or

About CSS Minification

CSS minification removes whitespace, comments, and unnecessary characters from a stylesheet to reduce its size before serving to browsers. The actual rules are unchanged: a minified stylesheet renders pages identically to the unminified source. The savings come from removing newlines, redundant semicolons, comments, hex-color shorthand opportunities, and zero-unit shortcuts (replacing 0px with 0).

On modern websites with dozens of style rules, the typical reduction is 20–40% versus the unminified source. Combined with gzip compression at the server, the marginal savings shrink — gzip already compresses repeated text effectively — but the combination still beats compression alone, particularly when stylesheets are cached and served many times to many visitors.

This minifier processes CSS in a single pass, removing comments outside of url() values, collapsing whitespace, removing redundant semicolons before closing braces, applying zero-unit shorthand, and converting six-digit hex colors to three-digit form where possible (#ffffff → #fff). The output remains valid CSS that any browser parses correctly.

Why Minify CSS

Smaller CSS files load faster and render-blocking time drops, both of which improve First Contentful Paint and Largest Contentful Paint scores. For sites where Core Web Vitals affect search ranking, every kilobyte of render-blocking CSS shaved is worth the effort.

Bandwidth costs also matter at scale. Sites that serve millions of page views save measurable amounts of egress when their stylesheets are 30% smaller. CDN bills, mobile data usage, and energy consumption all benefit slightly. Minification is essentially free — a one-time build step with no maintenance cost.

How to Minify CSS

Paste CSS, get the minified version.

  1. Paste your CSS: Drop a .css file or paste CSS source into the input area. The minifier accepts any valid CSS — modern syntax including CSS variables, calc(), grid, and flexbox.
  2. Choose options: Defaults remove comments, collapse whitespace, and apply common shortcuts. You can disable specific transformations if you need to preserve comments or particular formatting.
  3. Minify: The minifier walks the CSS, applying each enabled transformation. Output is functionally identical CSS with reduced size.
  4. Use the output: Copy or download. Replace the source CSS in your build output with the minified version, or run minification as a build step in your tooling.

Common Use Cases

Technical Details

CSS minification is mostly conservative whitespace removal. Whitespace inside selectors, declarations, and values is preserved where significant; whitespace outside is collapsed. Comments are removed unless they begin with /*! (license preservation comments).

Common shortcuts: 0px, 0em, and similar zero-unit values become 0; six-digit hex colors with paired digits (#ffffff, #336699) become three-digit (#fff, #369); the last semicolon before } is removed. Color names are not converted to hex automatically because hex is sometimes longer (red is shorter than #f00 in length; #ff0000 is longer than red).

Output should pass any CSS validator that accepts the input. Browser support is unchanged — minification does not modify the rules themselves, only their text representation.

Best Practices

Frequently Asked Questions

How much smaller will my CSS be?
Typically 20–40% reduction versus the unminified source. The exact ratio depends on how much whitespace and how many comments the source contains.
Will minification change how my page looks?
No. Minification preserves the rules exactly; only their text representation changes. The browser parses the minified CSS into the same rule set.
Are CSS variables and modern features supported?
Yes. Custom properties (--var-name), calc(), grid, flexbox, container queries, and other modern features are all preserved through minification.
Are comments preserved?
By default, no. Add /*! to the start of a comment to mark it as a license comment, which the minifier preserves.
Should I minify always?
For production yes. For development source files, no — readable CSS is essential for maintenance. Run minification at build time, not at edit time.
Is my CSS uploaded to a server?
No. The minifier runs in your browser.
How does this compare to cssnano or csso?
cssnano and csso are PostCSS plugins for production builds; they offer more aggressive transformations such as merging redundant rules. This tool covers basic minification for ad-hoc use without a build setup.
Does minification break source maps?
Minification does not generate source maps; this tool produces only minified output. To debug minified CSS in production, generate source maps as part of your build.