Code Tools

CSS Formatter

All tools

Expand a compressed stylesheet into one declaration per line so you can read and edit it.

How it works

Four simple steps

1

Add your CSS

Paste a stylesheet or drop a .css file onto the input.

2

Read the layout

Rules, declarations and nested @media blocks are indented live.

3

Switch to Minify

Press Minify when you want the compact version back.

4

Copy or download

Copy the result or save it as formatted.css.

CSS Formatter

About CSS Formatter

A third-party widget ships a single line of CSS and one of its rules is overriding your button styles. To find which selector is responsible, you need the file laid out properly. Paste it here and every rule, declaration and media query gets its own line.

The formatter walks the stylesheet character by character. An opening brace starts a new indented block, each semicolon ends a line, and closing braces step back out, so declarations inside @media and @supports rules end up two levels deep. Comments and quoted strings (font names, content values, url paths) are copied through untouched. Output refreshes as you type, you can drop a .css file onto the input, and Download saves formatted.css.

Formatting never reorders properties or removes duplicates, so if a property appears twice in a rule, the later one still wins. The readable layout simply makes those duplicates easy to spot. Once you know what is going on, compare selector weight with the specificity calculator, or minify the stylesheet again for production. For the HTML side of the same component, the markup formatter works the same way.

No stylesheet is sent anywhere for formatting. The parsing loop runs inside this tab, which is handy when the CSS comes from a client project under NDA.

Keyboard shortcut

Ctrl Enter - Run tool
FAQ

Frequently asked questions

See all FAQs

Answers for this tool. For site-wide help, open the FAQ hub.

No. Declarations keep their original order and duplicates stay in place. That is deliberate, because order decides which value the browser applies.

Nested SCSS and Less blocks indent correctly, because the tool only looks at braces, semicolons, comments and strings. It does not recognize // line comments, which can merge with the following line, so treat preprocessor source as a best effort.

Comments, line breaks, spaces around braces, colons, semicolons and commas, and the last semicolon in each block. Values are not rewritten, so colors and units stay exactly as you wrote them.

View more FAQs

Related tools

View all

HTML Formatter

Beautify and indent HTML markup.

Open

JS Formatter

Beautify JavaScript code.

Open

JSON Formatter

Beautify and validate JSON.

Open

XML Formatter

Format XML documents.

Open

Explore 321 free tools

Everything you need as a developer, marketer or creator - in one beautiful place.

Browse all tools