CSS Minifier and Beautifier - Compress or Expand

CSS minifier and beautifier

What this tool does

Two opposite jobs on the same stylesheet. Minifying strips what only humans need - comments and indentation. Beautifying puts it back so a file you inherited becomes readable. Both work on the text you gave, and both leave the meaning of the CSS alone.

How to use it

  1. 1 Paste the CSS - a whole file or a single rule.
  2. 2 Press Minify to compress, or Beautify to expand with indentation.
  3. 3 Check the byte count, then copy the result.

A space in a selector is not decoration

".a .b" matches a .b inside a .a; ".a.b" matches one element carrying both classes. They are different selectors, and a minifier that treats the space as slack silently paints the wrong elements. Here the space between two selector parts always survives - only the space around combinators like > and + is dropped.

calc() needs its spaces

In "calc(100% - 10px)" the spaces around the minus are required by the grammar: without them a browser reads "-10px" as a negative length, the expression becomes invalid and the whole declaration is thrown away. Nothing warns you - the layout is simply wrong. This tool never removes whitespace inside parentheses.

License comments stay

A comment that opens with /*! carries a copyright or licence notice, and by convention every minifier keeps it. Stripping it would remove the attribution a library asked you to ship. Ordinary /* comments are for you and your team, so those go.

Minifying CSS is worth less than gzip

Servers already compress stylesheets on the way out, and gzip is very good at repeated whitespace - so minifying on top of it usually saves a few percent, not half. Do it because the file is what ships and you want it small and stable, not because you expect the page to load noticeably faster.

CSS minification - frequently asked questions

Only whitespace and ordinary comments are removed, and the three places where whitespace carries meaning - selectors, parentheses and strings - are left alone. Nothing is renamed, reordered or merged, so the rules a browser sees are the same ones you wrote.
New
SQL Formatter Break a long query onto readable lines, or squeeze it back onto one. Keeps your keyword casing, your quoted names and your strings exactly as written.
Popular Today
JSON Formatter Format, minify and validate JSON in your browser. Broken input is pinpointed by line and column, and a collapsible tree shows the structure.

Related Dev Tools

JSON Formatter Format, minify and validate JSON in your browser. Broken input is pinpointed by line and column, and a collapsible tree shows the structure.
HTML Formatter Indent messy HTML so you can read it, or strip it down so it ships smaller. Works on fragments too, and never rewrites your markup into something else.
XML Formatter Indent messy XML so you can read it, or strip it down so it ships smaller. Handles RSS, CDATA and namespaces, and never rewrites your document.
SQL Formatter Break a long query onto readable lines, or squeeze it back onto one. Keeps your keyword casing, your quoted names and your strings exactly as written.

Other Tools You May Like

Word to PDF Convert Word to PDF for free: upload a DOC, DOCX, ODT or RTF file and download a properly formatted PDF in seconds - no registration or watermark.
PDF to Word Convert PDF to Word for free: upload a PDF and download an editable DOCX in seconds - no registration, no watermark and nothing to install.
Word Counter Free word counter: paste any text to count words, characters, sentences and paragraphs, and see the estimated reading time - nothing leaves your browser.
Character Counter Free character counter: count characters with and without spaces, plus words and lines, and check SEO limits for titles and meta descriptions.
Keyword Density Checker Free keyword density checker: paste text or a URL to see how often each word and phrase appears, with percentages for one, two and three-word terms.