DevTools Pro · All tools · About

CSS Formatter

About the CSS Formatter

This CSS formatter beautifies messy or minified stylesheets into readable, consistently indented code, and can minify CSS for production with one toggle. It works as you type, and strings, url() values and comments are never altered by the formatting.

Beautify vs minify CSS

Beautifying puts each declaration on its own line, indents rule bodies (including rules nested in @media or @supports), adds a space after every colon and places each selector of a list on a separate line. It is the version you want in source control and code review.

Minifying removes whitespace and comments, joins selectors with bare commas, drops the space around combinators (.nav > li becomes .nav>li) and removes the last semicolon before each }. That is the version you ship to browsers.

What minification keeps

Comments that start with /*! are kept when minifying. By convention these hold license or copyright notices that must stay in distributed files. All other comments are removed.

Text inside quotes and unquoted url(...) values is protected before formatting starts, so a data URI such as url(data:image/png;base64,iVBORw0KGgo=) or a content: "a b" value comes out byte for byte the same.

Common CSS syntax errors it reports

Instead of producing broken output, the formatter stops and tells you what is wrong: an unterminated /* comment, a string with no closing quote, an unexpected } (with its character position), or one or more { blocks that were never closed.

A missing closing brace is the most frequent cause. It usually comes from copying a rule out of DevTools or deleting part of a media query.

How to Use the CSS Formatter

  1. Paste your CSS into the Input CSS box.
  2. Under Format Type, choose Beautify for readable code or Minify for the smallest output.
  3. In Beautify mode, pick an Indent Size of 2, 4 or 8 spaces.
  4. Read the result in the Formatted Result (or Minified Result) panel. It updates on every keystroke.
  5. Click Copy to put the output on your clipboard, or Clear to start over.

Frequently Asked Questions

Is my CSS sent to a server?
No. Formatting and minification run in JavaScript in your browser, so the stylesheet never leaves your device.
Does minifying CSS change how it renders?
It should not. The minifier only removes whitespace, comments and the final semicolon in each block. It does not merge rules, shorten colors or reorder properties.
How much smaller does minified CSS get?
It depends on how much whitespace and commenting the source has. Hand-written, well-commented CSS often shrinks noticeably, while CSS that is already compact changes little. Gzip or Brotli on your server compresses it further.
Why are my comments missing after minifying?
Minify mode strips comments to save bytes. Start a comment with /*! if it must be kept, such as a license header.
Does it support CSS variables and modern syntax?
Yes. Custom properties like --brand: #ff0, calc(), var() and selectors with :is() or :not() are treated as ordinary text and formatted without changes to their meaning.
Can it format SCSS or Less?
Nested rule blocks indent correctly because the formatter tracks brace depth, but it is built for standard CSS. SCSS // line comments, mixins and Less functions are not parsed specially, so review the output.

Related tools