CSS Minifier
Minify CSS.
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
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?
Is it safe for calc()?
Does it remove comments?
How much smaller will the CSS be?
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 YouTubeHow base64 encoding works
Andrew Schmelyun
Mental model for Base64 encode/decode tools.
Watch on YouTube
- Introducing JSON
json.org
Canonical JSON grammar for formatters and validators.
- Regular expressions
MDN
JS regex guide aligned with browser-based testers.