Code Tools

CSS Minifier

All tools

Squeeze a readable stylesheet down to one compact line for production or inline use.

How it works

Four simple steps

1

Paste the stylesheet

Add readable CSS or drop a .css file onto the input.

2

Compression runs live

Comments, line breaks and spaces around punctuation are removed.

3

Check calc() lines

Restore spaces around + inside calc() if your CSS uses it.

4

Save the result

Copy the compact CSS or download min.css.

CSS Minifier

About CSS Minifier

You need to inline critical CSS into the head of a landing page, or paste styles into a platform that limits field length. Minifying the stylesheet first keeps the payload small and the markup tidy.

The minifier removes /* */ comments, collapses all whitespace, deletes spaces around { } : ; , > ~ and +, and drops the semicolon before each closing brace. Property values, colors and units are not rewritten, so #ffffff stays #ffffff. Results appear as you type, and the output can be copied or downloaded as min.css.

Watch for two edge cases caused by the space-stripping rule. Inside calc(), the + operator must have spaces around it, and the minifier removes them, so calc(100% + 2rem) becomes invalid; restore those spaces by hand (the minus operator is left alone). Second, a descendant selector such as .menu :hover loses its space and turns into .menu:hover, which targets a different element. If something renders differently, expand the output with the CSS Formatter and compare. Markup with style blocks can be compacted in the HTML minifier too.

The stylesheet is compressed locally with string replacements, so proprietary theme code is not shared with anyone.

Keyboard shortcut

Ctrl Enter - Run tool
FAQ

Frequently asked questions

See all FAQs

Answers for this tool. For site-wide help, open the FAQ hub.

No. It only removes whitespace, comments and redundant semicolons. Structural optimizations such as merging selectors or turning #ffffff into #fff are left to build tools.

CSS requires whitespace around + and - inside calc(). The minifier strips spaces around +, which makes the expression invalid. Add the spaces back around + in the output, or keep calc() rules out of the minified block.

Mostly. Whitespace inside quoted strings is collapsed like everywhere else, so a content value with double spaces ends up with one. URLs without spaces are unaffected.

View more FAQs

Related tools

View all

HTML Formatter

Beautify and indent HTML markup.

Open

CSS Formatter

Format and pretty-print CSS.

Open

JS Formatter

Beautify JavaScript code.

Open

JSON Formatter

Beautify and validate JSON.

Open

Explore 321 free tools

Everything you need as a developer, marketer or creator - in one beautiful place.

Browse all tools