My Tool Studio
Developer

CSS Minifier

Paste a stylesheet here to minify CSS in one click. The minifier removes comments, line breaks and spaces the browser does not need, drops the last semicolon in each rule, turns 0px into 0 where that is safe, and shortens hex colors such as #ffffff to #fff. License comments that start with /*! are kept unless you untick that option. It reads the CSS character by character, so calc(100% - 32px) keeps its required spaces, .card :hover keeps its meaning, and text inside quotes is never touched. Upload a .css file, minify several files at once and download them as a ZIP or one combined file, or turn on Live mode. The size before and after and a gzip estimate appear under the panes.

Always freeNo sign upRuns in your browser
Output appears here...

Minify several CSS files

Add several files, put them in order, then process them all with the options above. Files stay in your browser.

How to use

01

Paste or upload your CSS

Paste rules into the Input pane, or click Upload .css to load a file, which is minified straight away. Try sample loads a short stylesheet with a license comment, calc() and a media query.

02

Pick options and click Minify

Leave Keep /*! license */ comments and Shorten hex colors ticked, or untick them. Click Minify, or tick Live mode. Below the panes you see the original and new size, the percent saved and a gzip estimate.

03

Copy, download or batch

Click Copy, or Download to save a .min.css file. For several files, use Minify several CSS files: add them, set the order, then download each one, a ZIP, or one combined bundle.min.css.

Why CSS Minifier

Before and after: what minifying changes

The sample stylesheet has a license comment, a normal comment, 2-space indentation, blank lines between rules and a media query. Minifying it keeps the /*! license line, then gives one line that starts .hero{padding:0 16px;width:calc(100% - 32px);background:#fff;... and ends with @media (max-width:600px){.hero h1{font-size:32px}}.

Look at what stayed. The space in calc(100% - 32px) is still there because calc() needs it. The space between @media and the opening bracket is kept. 0px became 0 in the padding, but a 0px inside calc() would stay as it is, because calc() requires a unit. #AABBCC became #abc, while #0a0a0a stayed, because its digit pairs differ.

ChangeExample beforeExample after
Comments removed/* Hero */(nothing)
Spaces around { } : ; , removed.hero { padding: 16px; }.hero{padding:16px}
Last semicolon in a rule droppedmargin: 0;}margin:0}
Zero units shortenedpadding: 0px 16pxpadding:0 16px
Spaces kept where neededcalc(100% - 32px)calc(100% - 32px)
Hex colors shortened (optional)#ffffff and #AABBCC#fff and #abc
License comments kept (optional)/*! theme.css | MIT License */Kept on its own line

Minifying CSS in build tools

If your site has a build step, let it minify CSS on every deploy and keep this page for one-off jobs and checks. Build tools also handle things this page does not, such as removing unused rules, adding vendor prefixes and writing source maps, so your browser's DevTools can still point to the original line.

Common setups:

  • Vite minifies CSS in production builds by default, using esbuild unless you choose Lightning CSS.
  • webpack needs css-minimizer-webpack-plugin added to optimization.minimizer.
  • PostCSS setups usually add cssnano as the last plugin.
  • Parcel minifies CSS with Lightning CSS in production builds.
  • Next.js minifies CSS automatically when you run next build.
  • WordPress sites typically rely on a caching or optimization plugin that minifies stylesheets on the fly.

Common questions

Does minifying CSS break calc() or media queries?
Not with this tool. Spaces inside parentheses are kept, so calc(100% - 32px) stays valid, and a media query such as @media (max-width: 600px) only loses spaces it does not need. Some regex-based minifiers remove the spaces around + and - in calc(), which makes the rule invalid.
How much smaller does CSS get after minifying?
It depends on how much indentation, how many comments and how many long hex colors the file has. The size line under the panes shows the exact saving for your CSS, and for several files the batch panel adds up the total before and after.
Should I keep license comments when minifying CSS?
If a library's license asks you to keep its notice, yes. With Keep /*! license */ comments ticked, the default, comments that start with /*! stay in the output on their own line and all other comments are removed. Build tools such as cssnano treat /*! comments the same way.
Is it better to minify CSS by hand or in a build step?
For a site you update often, a build step is better, because every deploy gets fresh minified CSS without extra work. A browser tool like this one suits one-off jobs, such as a theme's custom CSS box, a stylesheet for an email, or checking what a minifier does to your code.
Does minified CSS help Core Web Vitals?
It can help a little. CSS blocks rendering, so a smaller file reaches the browser sooner and can improve First Contentful Paint and Largest Contentful Paint on slow connections. Removing unused CSS often saves more than minifying does.
Should I still gzip CSS after minifying it?
Yes. The two work together: minifying removes characters, and gzip or Brotli then compress the repeated patterns that remain. The gzip estimate under the panes shows roughly what a server would send.
How do I turn minified CSS back into readable code?
Click Beautify instead on this page, or use the CSS Beautifier for more layout options. Each rule and declaration goes on its own line with the indent you choose. Comments removed during minifying cannot be restored.
How should I minify CSS in WordPress?
Most caching and optimization plugins can minify theme and plugin stylesheets automatically, which is the usual route for a live site. For a one-off, paste the CSS here, minify it and paste it back, but keep a readable copy because you will want to edit it later.
What does this CSS minifier not do?
It does not merge duplicate rules, remove unused selectors or rewrite shorthand properties. It sticks to safe steps: comments and whitespace, 0px to 0 and, if you leave it on, #aabbcc to #abc. For deeper optimization, use cssnano or Lightning CSS in a build step.
Can I combine several CSS files into one minified file?
Yes. In Minify several CSS files, add the files, use the up and down arrows to set their order, and click Process. Download combined bundle.min.css joins them in that order, which matters because later rules override earlier ones. Download all as ZIP keeps them as separate .min.css files.

More Developer tools

View all