Format CSS, SCSS and Less one declaration a line: sort properties A to Z or grouped, drop comments, tidy values, errors by line
Unpack a stylesheet from a build or a CDN into one rule and one declaration per line, so you can read it and find what applies. SCSS and Less too.
How to use it
Paste CSS, SCSS or Less, or open a file. The syntax is found from the text (// comments and $variables mean SCSS); pick it under Syntax to be sure. Under Options: sort the declarations A to Z or in groups, drop comments, tidy values (0px to 0, #aabbcc to #abc), and put a blank line between rules or each rule on one line. Copy or download formatted.css. A brace left open is named with its line and column.
Examples
A minified button style
.btn{padding:8px 12px;border-radius:6px}.btn:hover{background:#0b5;color:#fff}.btn {
padding: 8px 12px;
border-radius: 6px;
}
.btn:hover {
background: #0b5;
color: #fff;
}Rules inside a media query
@media (max-width:600px){.nav{display:none}.menu{display:block}}@media (max-width: 600px) {
.nav {
display: none;
}
.menu {
display: block;
}
}SCSS with // comments and nesting
// theme
$brand: #0b5;
.btn{color:$brand;&:hover{color:darken($brand,10%)}}// theme
$brand: #0b5;
.btn {
color: $brand;
&:hover {
color: darken($brand, 10%);
}
}Read as SCSS, found from the // comment and $brand.
Sorted A to Z
.card{padding:16px;display:grid;color:#333;border:1px solid #ddd;-webkit-user-select:none;user-select:none}.card {
border: 1px solid #ddd;
color: #333;
display: grid;
padding: 16px;
-webkit-user-select: none;
user-select: none;
}The -webkit- form sits just before the standard one.
A shorthand after its longhand keeps its place
.box{margin-top:8px;margin:0;color:red}.box {
margin-top: 8px;
margin: 0;
color: red;
}Sorted, margin would come first and margin-top: 8px would win; here margin: 0 wins, so the rule stays as written, with a note.
Tidied values
.box{margin:0px 0px 8px;color:#FFCC00;width:calc(100% - 0px);transition:opacity 0s;flex:1 0px}.box {
margin: 0 0 8px;
color: #fc0;
width: calc(100% - 0px);
transition: opacity 0s;
flex: 1 0px;
}calc(), 0s and flex keep their units: a bare 0 there is invalid or means something else.
A rule left open
.a { color: red;; } .b { color: blueLine 1, column 21Unclosed block
Column 21 is the “{” of .b, which has no “}”.
What changes
Sort, tidy and lay out
Back to one line
Questions
- Does it read SCSS and Less?
Yes, found from the text (// comments, $variables and @mixin mean SCSS; @variables and .mixin(); calls mean Less) or picked under Syntax. Sass’s indented syntax (.sass files) isn’t read. Minify needs plain CSS, so compile SCSS or Less first. - Why is my stylesheet’s error on a different line than the one I edited?
A missing “}” is only noticed where the next rule starts, so the line named is where the reader gave up. The missing brace is somewhere above it. - Is my CSS uploaded?
No. Everything runs in your browser, so your CSS stays on your device. Nothing you paste is uploaded unless you share a result, which is locked with your password first.