CSS Minifier

Minify CSS.

FreeNo accountOn your device

Runs in your browser. How to verify

Loading tool…

About this tool

Paste CSS and get a smaller version with comments removed and whitespace collapsed outside strings and calc(). It is a fast text-based minifier, not a full optimiser, so it does not merge rules or shorten values.

How to use

1
Step 1
Paste your CSS.
2
Step 2
Press Run.
3
Step 3
Copy the minified CSS and check it renders correctly.

How it works

The tool deletes /* comments */, collapses runs of whitespace to one space, and then removes spaces around { }:;, > + and ~. It does not rewrite colours, merge selectors or drop the last semicolon in a block.

Worked example

A commented stylesheet

Input
/* hdr */ .btn { color: #fff; margin: 0 auto; } .btn > span, .x + .y { padding: 4px 8px; }
Output
.btn{color:#fff;margin:0 auto}.btn>span,.x+.y{padding:4px 8px}
Walkthrough
Comments, line breaks and the spaces around braces, colons and combinators are gone.

Limitations

  • Spaces inside calc() and inside quoted strings are kept; comments are removed and the last semicolon before } is dropped.
  • It is a whitespace minifier only: it does not shorten colours, merge rules or remove unused CSS.
  • For production builds, prefer a build-step minifier such as cssnano or Lightning CSS.

Questions

How do I minify CSS?
Paste it and press Run. Copy the compact output.
Is it safe for calc()?
Yes. Spaces inside parentheses, including calc(1px + 2px), are kept, because calc() requires them.
Does it remove comments?
Yes, all /* */ comments are removed.
How much smaller will the CSS be?
Typically the savings come from whitespace and comments, so expect a modest reduction on already-tidy CSS.

Features

  • Strips comments
  • Collapses whitespace
  • Runs in your browser

Related resources

Guides and videos from around the web—opens on YouTube or the publisher’s site.

  • What Is A RESTful API?

    Traversy Media

    API context for JWT, JSON, and encoding utilities.

    Watch on YouTube
  • How base64 encoding works

    Andrew Schmelyun

    Mental model for Base64 encode/decode tools.

    Watch on YouTube