CSS Minifier

Minify your CSS to reduce file size

Paste your CSS here...
Loading editor...
Loading editor...

CSS Minifier — Compress & Minify CSS for Production

Understanding the Basics

CSS minification is the process of removing all characters from a CSS file that are unnecessary for browser parsing — whitespace, comments, redundant semicolons, and unnecessary quotes — without altering any styling behavior. The result is a compact, single-line CSS string that the browser parses identically to the formatted version but delivers faster over the network. For context, the Bootstrap 5 framework's formatted CSS is 211 KB but minifies to 160 KB — a 24% reduction. For applications with large custom stylesheets (50–200 KB is common), minification can save tens of kilobytes per page load, meaningfully improving Core Web Vitals metrics like LCP (Largest Contentful Paint). Advanced minifiers go beyond whitespace removal: they merge duplicate selectors, remove unused declarations, convert color values to shorter equivalents (rgb(255,0,0) → #f00 → red), shorten zero values (0px → 0), and combine shorthand properties (margin-top/right/bottom/left → margin shorthand). Our minifier uses the clean-css library, one of the most comprehensive CSS optimizers available, which performs both safe whitespace removal and optional advanced structural optimizations.

How to Use the Tool

  1. Paste your CSS into the input editor.
  2. Choose the optimization level: Level 1 (safe whitespace and comment removal) or Level 2 (structural optimizations including shorthand merging and duplicate removal).
  3. Click "Minify" — the CSS is compressed and the size reduction percentage is displayed.
  4. Review the minified output in the right panel.
  5. Download the minified CSS for deployment to your CDN or production build pipeline.

Key Features & Specifications

  • Level 1: whitespace removal, comment stripping, and semicolon normalization (always safe)
  • Level 2: shorthand property merging, duplicate selector removal, and redundant property elimination
  • Color value shortening: converts rgb(255,0,0) → #ff0000 → #f00
  • Zero value shortening: converts 0px, 0%, 0em → 0
  • Displays original size, minified size, and compression percentage

Frequently Asked Questions (FAQ)

Q:Is Level 2 optimization always safe to apply?
Level 2 restructures the CSS, which in edge cases can alter specificity or override order in complex stylesheets. Test Level 2 output thoroughly before deploying to production. Level 1 is always safe — it only removes whitespace and comments, which never affect CSS behavior.
Q:Should I minify CSS in my build pipeline or use this tool?
For production deployments, CSS minification should be part of your automated build pipeline (webpack, Vite, Parcel, or PostCSS with cssnano). This tool is ideal for one-off minification, understanding what a minifier does, optimizing standalone CSS files not in a build system, and debugging minification output.
Q:Does CSS minification remove my CSS comments?
Standard comments (/* ... */) are removed during minification. Special "preserved comments" starting with /*! (the exclamation mark convention) are retained — this is how license headers and build attribution comments are kept in production minified files.