CSS Minifier — Minify and Compress CSS Online

Remove whitespace, comments, and compress CSS instantly

Minify CSS

Paste CSS to remove comments, whitespace, and unnecessary characters. See instant size reduction and compression ratio. All processing happens in your browser.

Compression Results

Original Size -
Minified Size -
Saved -
Compression Ratio -

Before & After Example

Original CSS (468 bytes)

/* Navigation styles */
.nav {
  display: flex;
  justify-content: space-between;
  padding: 1rem 2rem;
  background-color: #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.nav-item {
  margin: 0 10px;
  color: #333333;
  text-decoration: none;
}

.nav-item:hover {
  color: #00d4aa;
}

Minified CSS (201 bytes, 57% reduction)

.nav{display:flex;justify-content:space-between;padding:1rem 2rem;background-color:#fff;box-shadow:0 2px 4px rgba(0,0,0,.1)}.nav-item{margin:0 10px;color:#333;text-decoration:none}.nav-item:hover{color:#00d4aa}

What Gets Removed During Minification

Element Action Example
Comments Removed /* comment */ → removed
Whitespace Collapsed margin: 10px;margin:10px;
Line breaks Removed Multiple lines → single line
Last semicolon Removed {color:#fff;}{color:#fff}
Leading zeros Removed 0.5.5
Color codes Shortened #ffffff#fff
Zero units Units removed 0px0

How CSS Minification Works

CSS minification removes all characters that are not necessary for the browser to parse and render the stylesheet. This includes comments, indentation, line breaks, and trailing semicolons. The minifier also optimizes values like colors and units where possible.

The minified CSS is functionally identical to the original — same selectors, same properties, same values. The only difference is that it is compressed into the smallest possible representation. This significantly reduces file size without affecting how the CSS is applied.

Modern web development workflows typically minify CSS automatically during the build process using tools like cssnano, clean-css, or built-in minification in bundlers like Webpack or Vite. This tool is useful for quick one-off minification or when you do not have access to a build pipeline.

Common Use Cases for CSS Minification

  • Production deployment: Minify CSS before deploying to production to reduce page load times. Smaller files transfer faster, especially on mobile networks.
  • Performance optimization: Minification reduces file size by 30-60%, which improves Core Web Vitals scores (Largest Contentful Paint, Cumulative Layout Shift) used by Google for ranking.
  • Bandwidth savings: Smaller CSS files reduce bandwidth usage for both the server and users. This is especially important for high-traffic sites or users on metered connections.
  • Email templates: Inline CSS in HTML emails benefits from minification to reduce total email size and improve deliverability.
  • Testing minified output: Compare minified CSS from different tools or build configurations to verify correctness and size reduction.
  • Legacy projects: Quickly minify CSS for older projects that lack a build pipeline or automated minification step.

Best Practices for CSS Minification

  • Always keep source files: Never edit minified CSS directly. Keep the original formatted source and regenerate minified versions as needed.
  • Combine with gzip/Brotli: Minification reduces file size by 30-60%. Adding server-side compression (gzip or Brotli) on top of minification can achieve 80-90% total reduction.
  • Automate in build process: Use tools like Webpack, Vite, Gulp, or Parcel to minify CSS automatically during builds. Manual minification is error-prone and easy to forget.
  • Test after minification: Always test the minified CSS in a staging environment to ensure nothing broke. While rare, edge cases can cause issues.
  • Use source maps: Generate CSS source maps so browser DevTools can map minified CSS back to the original source for easier debugging.
  • Minify only for production: Use readable, formatted CSS during development. Only minify for production builds to keep debugging easy.

CSS Minification vs. Compression

CSS minification and compression are both file size reduction techniques, but they work differently:

Technique How It Works Typical Savings When Applied
Minification Removes comments, whitespace, optimizes values 30-60% reduction Build time (permanent change to file)
Gzip compression Compresses file using DEFLATE algorithm 60-80% reduction (on top of minification) Server sends compressed, browser decompresses
Brotli compression Modern compression algorithm (better than gzip) 70-85% reduction (on top of minification) Server sends compressed, browser decompresses

Best practice: Minify CSS at build time, then enable gzip or Brotli compression on your web server. This achieves maximum file size reduction with no tradeoffs.

Frequently Asked Questions

What does CSS minification do?

CSS minification removes all unnecessary characters from CSS code without changing functionality. This includes removing comments, whitespace between selectors and properties, line breaks, and unnecessary semicolons. It also optimizes values like shortening hex colors (#ffffff becomes #fff) and removing units from zero values (0px becomes 0). The minified CSS is functionally identical but significantly smaller.

Why should I minify CSS?

Minifying CSS reduces file size by 30-60%, which directly improves page load times, reduces bandwidth usage, and improves Core Web Vitals scores (metrics Google uses for ranking). Smaller files are especially important for mobile users on slower connections. Every kilobyte saved means faster initial render and better user experience.

Is minified CSS safe to use in production?

Yes. Minified CSS is functionally identical to the original. All major websites use minified CSS in production. The only difference is that it is harder for humans to read — which is why you should always keep the original formatted source files for development and only use minified versions in production.

Does CSS minification affect rendering or browser compatibility?

No. Minification only removes whitespace and comments. The CSS rules, selectors, properties, and values remain unchanged. Browsers parse and render minified CSS identically to formatted CSS. There are no compatibility concerns — if the original CSS works, the minified version will work identically.

Can I use this tool with CSS preprocessors like SASS or LESS?

This tool works with standard CSS only. If you use SASS, LESS, Stylus, or other preprocessors, compile them to CSS first, then minify the compiled output. Most modern build tools (Webpack, Vite, Parcel) include automatic minification as part of the compilation process.

How much file size can I save by minifying CSS?

Typical CSS files reduce by 30-60% when minified. Files with many comments, descriptive formatting, or deep indentation save more. For example, a well-commented 100 KB CSS file might reduce to 40-50 KB after minification. Adding server-side gzip or Brotli compression on top of minification can achieve 80-90% total reduction compared to the original.

Does this tool handle data URLs and encoded content in CSS?

Yes. This minifier preserves data URLs (including base64-encoded images), quoted strings, special characters in content properties, and escaped characters. It only removes whitespace and comments that are safe to remove without breaking functionality.

Should I minify CSS manually or use a build tool?

For production workflows, use a build tool (Webpack, Vite, Gulp, Parcel, Rollup) that minifies CSS automatically during the build process. This eliminates manual steps and ensures minification happens consistently. Use this online tool for quick one-off minification, testing minified output, or when you do not have a build pipeline set up.

Can I reverse minified CSS back to readable format?

Partially. You can reformat minified CSS to add line breaks and indentation (called beautifying or prettifying), but you cannot recover original comments, spacing conventions, or custom formatting. Always keep the original source files for editing — never edit minified CSS directly.

Does this tool send my CSS to a server?

No. All minification runs entirely in your browser using JavaScript. No CSS is transmitted over the network. No data is logged or stored. You can verify this by disconnecting from the internet — the tool works identically offline.

What is the difference between minifying and obfuscating CSS?

Minification removes unnecessary whitespace and comments while keeping selectors, property names, and values readable. Obfuscation goes further by renaming class names and IDs to shorter strings (e.g., .navigation becomes .a). Obfuscation requires updating HTML/JS to match renamed selectors and is typically done by specialized tools or frameworks. This tool only minifies — it does not obfuscate.

Why does my minified CSS look different from other tools?

Different minifiers use different optimization strategies. Some are more aggressive (e.g., reordering rules, merging selectors) while others are conservative (only removing whitespace). This tool uses a conservative approach to ensure safety. The output may differ slightly from tools like cssnano or clean-css, but all produce valid, functionally identical CSS.

Privacy & Limitations

  • Client-side only. No CSS is sent to any server. No cookies, no tracking, no logging.
  • Conservative minification. This tool removes whitespace and comments but does not reorder rules or merge selectors. For maximum compression, use a build tool like cssnano.
  • No preprocessing. This tool works with standard CSS. If you use SASS, LESS, or PostCSS, compile to CSS first.
  • Size limits. Browser-based processing handles files up to several megabytes. For very large CSS files, use a command-line tool.

Related Tools

Related Tools

View all tools

CSS Minifier FAQ

What does CSS minification do?

CSS minification removes all unnecessary characters from CSS code without changing functionality. This includes removing comments, whitespace, line breaks, and unnecessary semicolons. The minified CSS is functionally identical but significantly smaller in file size.

Why should I minify CSS?

Minifying CSS reduces file size by 30-60%, which means faster page load times, reduced bandwidth usage, and better performance — especially on mobile devices. Smaller files also improve Core Web Vitals scores used by Google for ranking.

Is minified CSS safe to use in production?

Yes. Minified CSS is functionally identical to the original. All major websites use minified CSS in production. The only difference is that it is harder for humans to read — use the original source files for development and minified versions in production.

Does CSS minification affect rendering or browser compatibility?

No. Minification only removes whitespace and comments. The CSS rules, selectors, properties, and values remain unchanged. Browsers parse and render minified CSS identically to formatted CSS.

Can I use this tool with CSS preprocessors like SASS or LESS?

This tool works with standard CSS only. If you use SASS, LESS, or other preprocessors, compile them to CSS first, then minify the output. Most build tools (Webpack, Gulp, Vite) include minification as part of the compilation process.

How much file size can I save by minifying CSS?

Typical CSS files reduce by 30-60% when minified. Files with many comments, descriptive formatting, or long indentation save more. Production sites also enable gzip or Brotli compression on top of minification for even greater savings (80-90% total reduction).

Does this tool handle data URLs and encoded content in CSS?

Yes. This minifier preserves data URLs, base64-encoded images, quoted strings, and special characters. It only removes whitespace and comments that are safe to remove without breaking functionality.

Should I minify CSS manually or use a build tool?

For production workflows, use a build tool (Webpack, Vite, Gulp, Parcel) that minifies CSS automatically during the build process. Use this online tool for quick one-off minification, testing, or when you do not have a build pipeline.

Can I reverse minified CSS back to readable format?

Partially. You can reformat minified CSS to add line breaks and indentation (called beautifying or prettifying), but you cannot recover original comments or variable names. Always keep the original source files for editing.

Does this tool send my CSS to a server?

No. All minification runs entirely in your browser using JavaScript. No CSS is transmitted over the network. You can verify this by disconnecting from the internet — the tool works identically offline.

Request a New Tool
Improve This Tool