Free SEO Tools

All tools

CSS Minifier

Remove comments, line breaks and spare spaces from a stylesheet without touching strings or the spaces that calc() needs.

Paste code and press Minify.

How to minify CSS

  1. Paste your stylesheet into the Paste your CSS box, or press Load a sample to see the tool in action straight away.
  2. Choose your options. Keep /*! licence */ comments is ticked by default, so copyright notices that start with /*! survive while ordinary comments are removed.
  3. Leave Keep the last semicolon before each } unticked for the smallest output. Tick it if another tool you use expects every declaration to end with a semicolon.
  4. Press Minify CSS. The line underneath shows the size before and after and the percentage saved.
  5. Press Copy result and paste the minified CSS into your theme, build folder or page builder.

Worked example

The sample is a short card component of 261 bytes. It has a comment at the top, indentation, a selector written as .card > h3 , with spaces around the combinator and comma, and a media query. Once minified, the result line reads 261 bytes → 193 bytes (26.1% smaller). The selectors become .card>h3,.card>h4, the media query becomes @media (max-width:600px) and the final semicolon in each rule is dropped. The quoted font name "Segoe UI" keeps its space, because spaces inside strings are meaningful.

A second check is worth doing with your own code. A declaration such as width: calc(100% - 2rem) comes out as width:calc(100% - 2rem). The spaces around the minus sign stay, because calc() stops working without them.

How it works

The minifier reads your CSS one character at a time. Comments are dropped unless they are licence comments you asked to keep. Quoted strings are copied exactly. Runs of whitespace are reduced to a single space, and that space is removed entirely next to characters where CSS does not need it: braces, semicolons, commas and the child combinator. Spaces that separate values, such as 0 0 .5rem, and the space inside a :hover-style selectors are kept, because removing them would change the meaning. Values themselves are never rewritten, so colours, units and numbers stay exactly as you wrote them.

Why smaller CSS helps

Stylesheets are render-blocking: a browser will not paint the page until it has downloaded and read the CSS in the head. Every kilobyte saved therefore shortens the wait before visitors see anything, which is especially noticeable on mobile connections. Smaller files also help Core Web Vitals measures such as Largest Contentful Paint. Minifying is only one step, but it is quick, safe and costs nothing.

Tips

  • Keep the readable version as your master file and minify a copy for the live site. Editing minified CSS by hand is slow and error-prone.
  • If your stylesheet is built with Sass or a bundler, switch on that tool's own compression instead. This page suits hand-written CSS, theme tweaks and snippets.
  • Keep licence comments for third-party code such as icon fonts or frameworks. Many licences require the notice to stay with the code.
  • After uploading, clear your site's cache and any CDN cache, or visitors may still receive the old file.
  • Combine small stylesheets into one before minifying to reduce the number of requests the browser has to make.
  • Check the result in your browser's developer tools if a rule seems to stop working.

Frequently asked questions

Will minified CSS look any different?

No. Browsers ignore comments and unnecessary whitespace, so the page renders exactly as before.

How much smaller will my file be?

Typically 15–35%, depending on how many comments and how much indentation the original contains. With gzip or Brotli compression on top, the transfer size falls further.

Does it remove unused CSS?

No. Removing unused rules needs your HTML as well and can easily break pages, so this tool only removes characters that never affect the result.

Is my CSS uploaded?

No. It is processed in your browser, and nothing is stored or sent.