Skip to content
Sealpaste

Delete all recent work?

This removes the 0 items saved in this browser. Your settings stay.

Stop saving recent work?

New work won't be saved in this browser. The 0 items already saved can stay or go.

CSS Formatter

CSS

Paste CSS, or

CtrlV paste · Ctrl↵ run now

Formatted CSS
Ready
Ln 1, Col 1
Runs in your browser. Nothing you paste is uploaded unless you share it.

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

  1. 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.
  2. 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.
  3. Copy or download formatted.css. A brace left open is named with its line and column.

Examples

A minified button style

Input
.btn{padding:8px 12px;border-radius:6px}.btn:hover{background:#0b5;color:#fff}
Result
.btn {
  padding: 8px 12px;
  border-radius: 6px;
}
.btn:hover {
  background: #0b5;
  color: #fff;
}

Rules inside a media query

Input
@media (max-width:600px){.nav{display:none}.menu{display:block}}
Result
@media (max-width: 600px) {
  .nav {
    display: none;
  }
  .menu {
    display: block;
  }
}

SCSS with // comments and nesting

Input
// theme
$brand: #0b5;
.btn{color:$brand;&:hover{color:darken($brand,10%)}}
Result
// theme
$brand: #0b5;
.btn {
  color: $brand;
  &:hover {
    color: darken($brand, 10%);
  }
}

Read as SCSS, found from the // comment and $brand.

Sorted A to Z

Input
.card{padding:16px;display:grid;color:#333;border:1px solid #ddd;-webkit-user-select:none;user-select:none}
Result
.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

Input
.box{margin-top:8px;margin:0;color:red}
Result
.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

Input
.box{margin:0px 0px 8px;color:#FFCC00;width:calc(100% - 0px);transition:opacity 0s;flex:1 0px}
Result
.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

Input
.a { color: red;; } .b { color: blue
Result

Line 1, column 21Unclosed block

Column 21 is the “{” of .b, which has no “}”.

What changes

Each rule starts on its own line, each declaration gets its own line ending in “;”, and a space follows every colon. Comments stay as written and values keep their meaning: hex colors and units go to lower case (#0B5 becomes #0b5, not #00bb55) and 10.0px becomes 10px.

Custom properties (--accent), nesting, @layer, @container and other modern CSS are read as they are. SCSS ($variables, @mixin, // comments) and Less (@variables, .mixin() calls) are read with Prettier’s own SCSS and Less parsers.

Sort, tidy and lay out

Sort puts the declarations in each rule A to Z, or Grouped: position first, then layout (display, flex, grid), box (width, margin, padding), border, text, look (background, opacity) and motion (transform, transition), the rest A to Z after. Custom properties come first, a -webkit- form just before its standard one, and a comment moves with the declaration it sits on. $variables, @include and nested rules stay where they are, and declarations sort only between them.

In CSS the later of two declarations wins. A rule where sorting would turn a shorthand and its longhand around (margin-top: 8px, then margin: 0) keeps its order, and a note says how many did.

Tidy values writes zero lengths as 0 (0px, 0em) and six-digit colors that repeat as three (#aabbcc to #abc). It leaves calc(), var() and url() alone, keeps 0s and 0deg, leaves the flex shorthand alone (in flex: 1 0, the bare 0 is the shrink factor, not the basis) and custom properties as written.

Rules: Blank line between puts an empty line after each rule; One per line writes each rule that holds only declarations on one line (.a, .b { color: red; margin: 0; }). Comments: Drop removes every comment, /*! license comments too.

Back to one line

Switch Mode to Minify to shrink it again: comments go, colors and zeros get shorter, and rules with the same declarations are merged. The status bar says how much smaller it is, in bytes.

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.

Related tools