CSS Minifier

Paste a stylesheet and the minified version appears below, with the bytes saved. It removes comments and whitespace and leaves every value exactly as you wrote it.

How it works

The minifier reads your CSS as tokens: strings, comments, url() values, punctuation and words. It then writes them back without the comments and without any space the browser does not need.

Some spaces matter, and those stay. "calc(100% - 2rem)" needs the spaces around the minus sign. ".nav :hover" and ".nav:hover" select different things. Text inside quotes is never touched.

It does not rewrite values. #ffffff stays #ffffff and rules are never merged or reordered. That costs a few bytes, but it means the output behaves exactly like the input. The work happens on this page, and your CSS is not uploaded.

How to use it

  1. 1 Paste your CSS into the first box.
  2. 2 The minified CSS appears in the second box as you type, with the size before and after.
  3. 3 Press Copy result, or download it as a .css file.

Good to know

  • Comments that start with /*! are kept. Use that form for licence notices that must stay in the file.
  • Keep the readable file as your source and minify a copy. Minified CSS is hard to edit by hand.
  • Your server probably compresses CSS with gzip or Brotli already. Minifying still helps, but the saving on the wire is smaller than the saving on disk.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

Minifying a small stylesheet by hand, and the spaces you must keep

Take a small stylesheet for a button. It starts with a comment, /* Buttons */. Then comes a .btn rule with three declarations: color: #ffffff, margin: 0px 0px 0px 0px, and a background with url("icons/arrow.svg") no-repeat. Next is a hover rule written as ".btn :hover" with width: calc(100% - 2rem). After that is a licence comment, /*! MIT licence */, and a media query for screens up to 600px wide in portrait, which sets display: block !important. Laid out with line breaks and two-space indents, the file is 274 bytes.

Most of the work is plain removal. The /* Buttons */ comment goes, because the browser never reads it. The line breaks and indents go. The space after the colon in each declaration goes, and so does the space before each opening brace. The last semicolon in each block goes too, because CSS only needs a semicolon between declarations, not after the last one. "!important" loses its leading space. The result is 224 bytes, about 18% smaller, and it is one long line.

A few spaces survive, and each one matters. The first is in ".btn :hover". With the space, the rule matches any element inside a button while it is hovered. Without the space, ".btn:hover" matches the button itself. A minifier that removed it would change your page. The next two are inside calc(100% - 2rem). CSS requires spaces around + and - in calc(), so "100%-2rem" is invalid and the browser drops the whole declaration. The last is in the media query: "and (orientation: portrait)" needs the space between "and" and the bracket. The minifier knows each of these cases and keeps them.

Some things the minifier deliberately leaves alone. The licence comment stays, because a comment starting with /*! is the usual way to mark text that must ship with the code. The url() value and the quoted file name are copied as they are. #ffffff is not shortened to #fff, and the four zero margins are not collapsed to "0". A more aggressive tool would make those changes and save another 17 bytes. The trade is that each rewrite is a place where a bug can change your layout. This tool chooses output you do not have to retest.

There are limits worth knowing. The tool does not remove unused rules, because it cannot see your HTML. It does not merge duplicate selectors or reorder anything. It also does not check that your CSS is valid: a missing brace stays missing. Finally, the saving you see is the saving on disk. If your server already sends CSS with gzip or Brotli, as most do, the difference on the wire is smaller, because compression already shrinks repeated whitespace well.

Frequently asked questions

Will minifying change how my page looks?

It should not. The minifier only removes comments and whitespace that CSS ignores. It keeps the spaces that change meaning, such as the one in ".nav :hover" and the ones around + and - inside calc().

Why is #ffffff not shortened to #fff?

Rewriting values is where minifiers break stylesheets, so this one does not do it. Shorter colours and merged rules would save a few more bytes, but you would then need to test the result. Here the output is the same CSS with less space in it.

Does it keep licence comments?

Yes. A comment that starts with /*! stays in the output. Every other comment is removed.

Does it remove CSS I do not use?

No. It cannot see your HTML, so it cannot know which selectors match nothing. Every rule you paste is in the output.

Is my CSS sent to a server?

No. The minifier is JavaScript running on this page. Nothing you paste leaves your device.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.