CSS Minifier and Beautifier: Compress CSS Online

This online css minifier and beautifier makes stylesheets smaller or cleaner. Paste CSS and minify it to strip spaces and comments, or beautify it with neat indents to read and edit. See the size saved and copy or download it.

CSS Minifier & Beautifier

Compress or format stylesheets.

Everything runs in your browser. Nothing you enter or upload is sent to a server.

How to use the CSS Minifier & Beautifier

  1. Paste your CSS.
  2. Press Minify to compress it or Beautify to format it.
  3. See the size saved.
  4. Copy or download the result.

How it works

Strings are protected first so their content is never changed. Then comments are removed, whitespace is collapsed, spaces around { } : ; , and > are removed, and the last semicolon in each block is dropped. Beautify adds line breaks and two-space indentation.

Example

a {\n color: red;\n margin: 0px auto;\n} becomes a{color:red;margin:0 auto}.

Frequently asked questions

How much smaller does CSS get?

Typically 20% to 40%, more if there are many comments.

Is minified CSS slower?

No, it loads faster and works the same.

Is my CSS uploaded?

No. Everything runs in your browser.

See also: JSON Formatter.

Minify or format CSS

How to use it

  1. Paste your CSS.
  2. Pick minify or beautify.
  3. Check the size saved.
  4. Copy or download.

More questions

Will minifying break my styles?

It should not, but test before you ship.

Are comments removed?

Yes. Comments are removed when you minify your CSS.

Is my code uploaded?

No. Everything stays in your browser on your device.

Related tools: JavaScript Minifier and Beautifier, HTML Formatter and Minifier, CSS Box Shadow Generator.

A short rule set, minified and beautified

Paste your CSS and press Minify or Beautify. Keep the zero-unit option on to turn 0px into 0. To test your minified CSS with live HTML, use the Online HTML Editor.

Worked example: a 73-byte rule set with a comment and "padding: 0px" minifies to body{margin:0;padding:0}.btn{color:#ffffff}, 43 bytes, a 41% saving. Beautifying body{margin:0;padding:0}.btn{color:#fff} returns it with 2-space indents.

More answers

What does the zero-unit option do?

It rewrites values such as 0px as 0, which saves bytes without changing the layout. In the example, padding: 0px becomes padding:0.

How do I turn minified CSS back into readable code?

Paste the minified rules and press Beautify. body{margin:0;padding:0}.btn{color:#fff} comes back with one declaration per line and a 2-space indent.