CSS Formatter & Beautifier
This CSS formatter turns minified or messy CSS into clean, consistently indented code.
CSS input
Formatted CSS
How to format CSS
- Paste compressed or messy CSS on the left, or open a
.cssfile. - The formatted stylesheet appears on the right as you type.
- Choose 2 spaces, 4 spaces or tabs.
- Copy the result or download it as a
.cssfile.
Before and after
.nav{display:flex;gap:1rem}.nav a{color:var(--link,#2563eb)}@media (max-width:600px){.nav{flex-direction:column}}.nav {
display: flex;
gap: 1rem
}
.nav a {
color: var(--link, #2563eb)
}
@media (max-width:600px) {
.nav {
flex-direction: column
}
}What stays exactly as it was
Formatting only changes whitespace and line breaks. The formatter (js-beautify) keeps strings and content values, url() and data URLs, calc() expressions, custom properties and var(), comments, and at-rules such as @media, @supports and @keyframes. Unclosed strings, comments or brackets are reported with their line and column, because formatting broken CSS would only hide the problem.
Use cases
- Reading the minified stylesheet of a website or a UI library.
- Cleaning up CSS copied from the browser's dev tools or an email template.
- Giving a stylesheet consistent indentation before a code review.
Media queries and nested rules
Minified stylesheets often hide media queries on one line. The formatter gives every rule its own block and indents rules inside @media, @supports and @layer one level deeper:
a{color:red}@media (max-width:600px){.x{display:none}}a {
color: red
}
@media (max-width:600px) {
.x {
display: none
}
}Property order, values and selectors are never changed, so the formatted stylesheet renders exactly like the original.
Other CSS and JavaScript tools
Compress stylesheets for production with the CSS minifier. Formatting JavaScript or markup too? Use the JavaScript formatter and the HTML formatter, and try your styles live in the online HTML editor.
Frequently asked questions
- Will formatting change my styles?
- No. Only whitespace and line breaks change. Values, strings, url() and data URLs, custom properties and comments stay exactly as they are.
- Can it unminify CSS from a production site?
- Yes. Paste the minified stylesheet and every rule, declaration and @media block is put on its own line with consistent indentation.
- Does it work with SCSS or Less?
- Plain CSS is the target. Simple SCSS and Less usually format fine, but their special syntax (mixins, maps, nested properties) isn't understood and may be laid out unusually.
- Does the CSS formatter sort or merge properties?
- No. It only changes whitespace and line breaks. Sorting or merging declarations can change which rule wins, so the order is always kept exactly as written.