CSS minifier

Minify CSS by stripping comments and unneeded whitespace. Keeps /*! license */ comments, strings and url() values intact. Instant, and runs in your browser.

Processed locally in your browser
Loading tool…

About CSS minifier

The CSS minifier removes comments, line breaks and spaces a browser does not need, turning a formatted stylesheet into a compact single line. Paste CSS or open a file and the minified result appears immediately, with its character count in the status bar.

The minifier keeps quoted strings, unquoted url() contents and important comment markers while removing unnecessary spacing. It does not merge rules or rename selectors. Review the result in its destination: complex CSS, custom properties and application-specific conventions still need a browser test.

How to use CSS minifier

  1. Paste CSS into the input box, or open or drop a .css file.
  2. Review the minified output and its character count.
  3. Copy the result or download it as a .css file.

Features

  • Removes comments, except those starting with /*! such as license headers.
  • Removes whitespace around braces, semicolons, commas, colons and the > and ~ combinators.
  • Drops the last semicolon in each declaration block.
  • Keeps quoted strings, url() values and meaningful spaces, such as those in selectors and calc() expressions, unchanged.
  • Reports an unclosed comment, string or url() instead of producing broken output.

Common uses

  • Shrinking a hand-written stylesheet for a small site with no build step.
  • Inlining critical CSS in the <head> of a page.
  • Embedding CSS in an email template, widget or JavaScript string.
  • Checking how much of a stylesheet’s size is formatting and comments.

Frequently asked questions

Does the CSS minifier optimize values or merge rules?

No. It removes comments and unnecessary whitespace only. Tools such as cssnano or Lightning CSS also shorten colors, merge duplicate rules and drop overridden declarations, which saves more bytes but changes the stylesheet’s text. This tool keeps every rule and value as written.

Why is the /*! comment still in the output?

Comments that begin with /*! are a widely used convention for license and copyright notices that must stay in distributed files. All other comments are removed.

Can removing whitespace break CSS?

Some spaces matter: a :hover matches any hovered element inside a link, while a:hover matches the link itself, and calc() needs spaces around + and -. The minifier keeps spaces in those places and inside strings, and removes them only where CSS ignores them.

What is the difference between minifying and compressing CSS?

Minifying rewrites the file itself without unnecessary characters. Compression, such as gzip or Brotli, is applied by the web server during transfer and reversed by the browser. They work together, though the extra saving from minifying is smaller once a file is compressed.

How do I make minified CSS readable again?

Use the CSS formatter, which reindents a stylesheet with Prettier. Comments removed during minification cannot be recovered, so keep your original source files.

Is my input uploaded?

Tools run in your browser. Files, text and results are not uploaded to our servers and are cleared when you leave the tool.

Your privacy comes first

Tools run in your browser. Files, text and results are not uploaded to our servers and are cleared when you leave the tool.

Find your next tool
↑ ↓ · Enter ↵Esc · Close search