CSS Formatter
Paste CSS and get tidy, consistently indented code, or a compact minified version.
INPUT
CHARS: 0WORDS: 0LINES: 0
OUTPUT
CHARS: 0WORDS: 0LINES: 0
How the CSS Formatter works
Beautify mode formats the stylesheet using Prettier, a widely used code formatter. Rules are broken onto separate lines, declarations are indented, spacing around colons and braces is normalized and long selector lists are wrapped sensibly.
Minify mode removes comments and unnecessary whitespace and trims the final semicolon in each block. Minifying here is a basic transformation, so for large production builds use a dedicated build tool that can also merge rules.
CSS Formatter examples
Format minified CSS declarations
Input
.btn{display:inline-block;padding:8px 16px;border-radius:4px;color:#fff;background:#333;}Result
.btn { display: inline-block; padding: 8px 16px; border-radius: 4px; color: #fff; background: #333; }
When it is useful
- •Reading CSS copied from a minified production file.
- •Standardizing the indentation of styles from different authors.
- •Shrinking a small snippet before pasting it into an inline style tag.
- •Spotting syntax errors, since the formatter reports where parsing fails.
Frequently Asked Questions
Does it change what my CSS does?
Beautifying only changes whitespace and line breaks. Minifying removes comments and whitespace but keeps every declaration.
What if my CSS is invalid?
The formatter shows the first parse error with its position instead of producing partial output.
Can it format SCSS or Sass?
Use the SCSS Formatter for SCSS syntax such as nesting and variables.
Related tools
- SCSS FormatterClean up SCSS so that nesting and declarations read clearly.
- HTML Formatter, Minifier and BeautifierClean up markup, or squeeze it down for production.
- Color ConverterType or pick a color and copy it in any format.
- JavaScript FormatterMake minified or messy JavaScript readable.