Beautify or minify CSS with 2-space, 4-space, or tab indentation. See the exact byte savings percentage after minifying β copy the result with one click.
Paste CSS and choose Beautify or Minify
Cascading Style Sheets (CSS3) dictates the visual presentation, responsive layout grid, and typographic hierarchy of web applications. As style files expand across component libraries, minifiers, and rapid iterations, CSS rules often become inconsistent, duplicated, and difficult to maintain. Formatting CSS enforces consistent property declaration order, cleans up duplicate selectors, standardises colour notations, and ensures clean team Git diffs.
Professional frontend development guidelines (such as Concentric CSS or idiomatic CSS) recommend grouping declarations logically rather than sorting alphabetically:
position, top, right, bottom, left, z-index, float, cleardisplay, flex, grid, align-items, justify-content, width, height, margin, paddingfont-family, font-size, font-weight, line-height, letter-spacing, text-align, colorbackground, background-color, border, border-radius, box-shadow, opacitytransition, transform, animation, will-change| Bad / Inconsistent Formatting | Standardised Formatted CSS |
|---|---|
.card{color:#fff;padding:10px;display:flex;border:1px solid #ccc;} | <pre>.card { |
| display: flex; | |
| padding: 10px; | |
| border: 1px solid #ccc; | |
| color: #ffffff; | |
| }</pre> |
#ffffff instead of #FFF) or modern functional notations (hsl(), oklch()).div > ul > li > a.active) that make CSS overrides unnecessarily difficult.JavaScript / Node.js (Prettier API)
import prettier from 'prettier';
async function beautifyCss(rawCss) {
return await prettier.format(rawCss, {
parser: 'css',
tabWidth: 2,
singleQuote: false,
});
}
const unformatted = "body{margin:0;padding:0;background:#f0f0f0}";
beautifyCss(unformatted).then(console.log);
Python (cssbeautifier)
import cssbeautifier
options = cssbeautifier.default_options()
options.indent_size = 2
res = cssbeautifier.beautify("a{color:red;font-size:12px;}", options)
print(res)
-webkit-, -moz-) automatically.This website and utility are provided for general informational, calculation, and educational purposes only. Always verify critical computation outputs prior to professional deployment or financial use. See our Terms of Service and Privacy Policy for full governance details.