CSS Minifier

Remove CSS formatting with a real parser while preserving rule order and custom property values.

✓ Free to use · Runs in your browser · No sign-up

Make your code smaller

Paste source code, then select Minify. The output is text only: your code is never run.

Removes formatting with a CSS parser. Custom property values are preserved; selectors and rules are not reordered. Check the result in your target browsers.

Your data is processed locally in your browser and is not uploaded to our servers.

Up to 100,000 characters. Paste text, not a file URL.

How to use CSS Minifier

  1. Paste your stylesheet, including its selectors and declarations.
  2. Select Minify and check the resulting byte count.
  3. Copy the output or download it as a .css file, then test it with the page that uses it.

A closer look

CSS minification requires understanding syntax: a space in a selector can select descendants, and spaces around operators can matter in calc(). This tool uses CSSTree to parse and regenerate compact CSS. It removes formatting without reordering rules or making structural optimization assumptions. Custom property values are retained as raw values because they may contain unusual token sequences used later by var(). Strings, URLs, nested rules, and function syntax are handled by the parser instead of global text replacements.

A practical example

Minify p { color: red; } to a compact rule such as p{color:red}. Rule order and meaningful selector spacing are preserved.

A useful tip

This is formatting minification, not a full CSS validator or compatibility checker. Unsupported grammar may be rejected, while unknown property names can be retained. Comments are normally removed, so keep any required license notice separately.

Good questions. Simple answers.

Does it download imports or URLs?

No. Referenced URLs stay as text in the stylesheet. There is no network fetch or stylesheet injection.

Does it remove unused styles?

No. Determining whether a selector is unused requires the consuming application. This tool keeps rule order and does not inspect your website.

Explore all developer tools for related tasks and category-specific guidance, or read how Toolzafi handles your data.

A few more useful tools