CSS Beautifier and Minifier
WM-72Paste CSS to beautify it with the indent you choose, or minify it and see how many bytes you saved. Beautify and Minify sit side by side.
Runs in your browser. Nothing is uploaded.
CSS
Result
How to use it
- Paste your CSS into the input box, or open a .css file or drop it on the box.
- Pick an indent from 1 to 10 spaces, or a tab.
- Choose Beautify for readable CSS, Minify for one line, or Size saved for the byte count.
- Copy the result or download it as a .css file.
Beautify
Beautify puts every selector and declaration on its own line and indents declarations by the width you pick, from 1 space to 10, or a tab. Selector lists are split one selector per line, and a blank line separates rules. Comments are kept. Nested at-rules such as @media are indented a level. It does not sort properties, merge rules or change any value.
Minify
Minify removes every comment, including /*! license */ comments, collapses whitespace, drops the last semicolon in each block and keeps strings and url() values as written. It does not shorten colors or numbers, merge rules or rename anything, so the saving is whitespace and comments only. Size saved shows the byte count before and after, counted as UTF-8 bytes, not characters.
When this is the wrong tool
This handles plain CSS. SCSS and Less add nesting, variables and // comments that plain CSS does not have, so use the SCSS beautifier for those. A stylesheet with an unclosed string, comment or brace is reported before anything changes, which helps you find a stray quote that would break the rest of the file.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
String starting at line 1 is never closed (missing "). | A quoted string has no closing quote. | Add the closing quote on the line shown. |
1 block opened with { and never closed (missing }). | A { has no matching }. | Add the closing brace at the end of the rule. |
Questions people ask
How do I beautify CSS online?
Paste the CSS and choose Beautify. Each selector and declaration goes on its own line, indented by the width you pick. Copy the result or download it as a .css file. Nothing leaves your browser, so private stylesheets are fine to paste.
How do I minify CSS?
Choose Minify. Comments and extra whitespace are removed and the last semicolon in each block is dropped, so the stylesheet becomes one line. Strings and url() values are kept exactly. Click Size saved to see the before and after byte counts.
What indent sizes can I choose?
1, 2, 3, 4, 5, 6, 8 or 10 spaces, or a tab. Two and four spaces are the common choices. The setting only affects Beautify, because Minify removes indentation altogether.
Does minifying change how my page looks?
It should not. Only comments and whitespace are removed, and strings and url() values are untouched. It does not merge rules or shorten values, which are the steps that sometimes change results. Always test a minified file once before deploying it.
Is there a difference from the CSS formatter?
This page puts Beautify and Minify together with a wider choice of indents and a size report. The CSS formatter on this site uses the same engine with 2 spaces, 4 spaces or a tab. Pick whichever has the options you need.
Why does it complain about my stylesheet?
Before changing anything, it checks that strings, comments and braces are closed. A missing quote or brace anywhere would break everything after it, so the error names the line or counts the unclosed braces. Fix the first one and run it again.
About this tool
Beautify uses the js-beautify library and puts each selector and declaration on its own line with the indent you pick, from 1 to 10 spaces or a tab. Minify is our own code: it removes every comment, including /*! license */ comments, collapses spaces, drops the last semicolon in each block, and keeps strings and url() values as written. It does not shorten colors or numbers, merge rules, reorder anything or rename anything. Size saved reports the byte count before and after minifying. Unclosed strings, comments and braces are reported before anything is changed. For SCSS or Less source, use the SCSS beautifier, because nested rules and // comments are not plain CSS.