Skip to content

CSS Formatter & Minifier

Beautify CSS for readability or minify for production. See exact size savings.

Related Tools

HTML Encoder & Decoder Strip HTML Tags Code Playground HTML Preview JSON Formatter & Validator

How to Use

  1. Paste Your CSS — Type or paste your CSS code into the editor. The input stats show line count, file size, number of style rules, and number of declarations in real-time.
  2. Choose Beautify or Minify — Click Beautify to format your CSS with proper indentation, line breaks, and spacing. Click Minify to compress it by removing comments, optional whitespace, and the last semicolon in each block.
  3. Copy or Download — The output shows the processed CSS with a size comparison. Copy to clipboard or download as a .css file. The stats show exact size savings for minification.

About the CSS Formatter & Minifier

The CSS Formatter & Minifier does two opposite jobs. Beautify turns compressed or messy CSS into consistently indented, readable code. Minify strips everything a browser does not need, so the file downloads faster. Front-end developers use it to read a minified third-party stylesheet, tidy CSS copied from browser developer tools, or compress a small stylesheet without setting up a build step.

How it reads your CSS

Instead of search-and-replace, the tool runs a small tokenizer and parser. It recognizes comments, quoted strings, brackets and url(…) values, then builds a tree of rules, declarations and at-rules (@media, @supports, @keyframes and nested blocks at any depth). So the colon in a:hover or ::before is never mistaken for a property colon. The // and ; inside an unquoted url(data:…) are never split, and spaces inside strings are never touched.

What each button does

Worked example

Input (149 bytes):

/* Buttons */
.btn,.btn:hover>span{color:#FFFFFF;margin:0px 0 0 0}
@media (max-width:600px){
  .btn { padding : calc(1rem + 2px) 8px !important ; }
}

Beautify:

/* Buttons */
.btn,
.btn:hover > span {
  color: #FFFFFF;
  margin: 0px 0 0 0;
}

@media (max-width:600px) {
  .btn {
    padding: calc(1rem + 2px) 8px !important;
  }
}

Minify (122 bytes; the stats line reads 149 B → 122 B (18% smaller, saved 27 B)):

.btn,.btn:hover>span{color:#FFFFFF;margin:0px 0 0 0}@media (max-width:600px){.btn{padding:calc(1rem + 2px) 8px!important}}

The values themselves are untouched in both outputs: #FFFFFF is not shortened to #FFF, and 0px stays 0px.

Limitations

Practical tips

Formatting and minification run in your browser, so your stylesheet never leaves your device.

Frequently Asked Questions

What does the Beautify option do?

Beautify reformats your CSS with consistent indentation (2 spaces), each declaration on its own line, a space after each property name's colon, each selector of a list on its own line, and blank lines between rule sets. Colons inside selectors such as a:hover or ::before, quoted strings, and url() values are left exactly as written. Comments are preserved, and nested rules (like media queries) are properly indented.

What does the Minify option do?

Minify removes comments, line breaks, optional whitespace, and the last semicolon before each closing brace. It removes spaces around braces, semicolons, commas, the colon between a property and its value, and the > + ~ selector combinators. Spaces that matter are kept: the descendant space in a selector like .nav :hover, the spaces around + and - inside calc(), and everything inside quoted strings. Size reduction depends on how the CSS was formatted: the more comments, indentation, and line breaks it has, the more it shrinks. The stats line shows the exact saving for your file.

Does minification break my CSS?

No. Minification only removes characters that are syntactically optional — comments, whitespace that has no meaning, and the last semicolon before a closing brace. The minifier reads your CSS token by token, so selectors, property values, strings, and url() addresses are never rewritten, and valid CSS renders the same before and after minification. As with any tool, keep a copy of your original source for editing.

Can I format minified CSS back to readable?

Yes. That is exactly what Beautify does. Paste minified CSS, click Beautify, and get properly indented, readable code. This is useful for debugging production CSS or understanding third-party stylesheets.

Does it handle CSS comments?

Beautify preserves comments and formats them on their own lines. Minify removes all comments entirely, which is the standard behavior for production CSS minification. If you need to preserve specific comments (like license headers), add them back after minification.

Is my CSS sent to a server?

No. All formatting and minification happens in your browser using JavaScript string processing. Your CSS code is never transmitted to any server or external service. The tool works entirely offline once loaded.