What is css formatter?
Minified or copied CSS is hard to read. A formatter adds line breaks and indentation so you can scan rules and fix mistakes.
The tool keeps your selectors and values as they are and only changes whitespace.
How to use the css formatter
- Paste CSS into the box.
- Pick an indent style.
- Press Format CSS and copy the result.
How the css formatter works
The formatter walks through the text, tracks braces and strings, puts each declaration on its own line and indents nested blocks such as media queries.
Worked example
Common uses of the css formatter
- Reading minified stylesheets.
- Code review.
- Learning from a copied style.
- Cleaning pasted CSS.
- Preparing documentation.
Tips and common mistakes
Format before reviewing or debugging.
Use the CSS minifier before publishing.
Keep comments, since they are left in place.
Background: what to know before you rely on it
Readable code reduces mistakes and makes teamwork easier. Browsers ignore extra whitespace, so formatting has no effect on how a page looks, only on how people read the source.
Private, free and fast
This tool runs in your browser. What you type or choose is not sent to a server and is not saved after you close the page. No sign in is needed. It is free to use as often as you like. See more in all developer tools, or browse the full list of tools.
Field by field guide
- CSS code: Type or paste your text here. Use a new line for each entry where the label says so.
- Indent: Choose one of: 2 spaces; 4 spaces; Tab.
Change one field at a time to see how the result responds, and use the worked example above to check that you get the same answer.
Working with CSS in practice
A formatter changes layout only, so the browser renders the stylesheet exactly as before. That makes it safe to run on any file before review.
Practical scenarios
- Opening a minified vendor stylesheet to find which rule sets a color, then reading it with one declaration per line.
- Cleaning a stylesheet pasted from a design tool before committing it, so the diff shows real changes instead of spacing noise.
- Checking that a long selector list is not duplicated by scanning one selector per line.
Common mistakes
- Expecting the tool to fix invalid CSS. A missing semicolon or brace stays missing, so validate in your browser developer tools.
- Formatting a file that mixes tabs and spaces and then comparing it with the old version. Convert the old one too or the diff is noisy.
- Using a formatter when you need a smaller file. Use the CSS minifier for production.
A tidy stylesheet
Readable CSS reduces bugs. Group related rules, keep one declaration per line and order properties in a repeatable way, such as layout, box model, typography, then color.
Expert tips
- Use lowercase hex colors and consistent units, such as rem for type and px for borders.
- Keep selectors short. Deep nesting increases specificity and is hard to override.
- Place media queries next to the rules they change or at the end, and stay consistent.
- Remove unused rules with the coverage tool in browser developer tools.
- Add a short comment above each section.
A formatter handles layout only. A linter such as Stylelint finds mistakes and enforces rules.
Frequently asked questions
Does it change my CSS?
No. Only spacing and line breaks change.
Can it format SCSS or LESS?
Simple nesting works, but it is built for plain CSS.
Is my code uploaded?
No.
Can I reverse it?
Yes, use the CSS minifier.
Related tools
HTML Formatter
Paste your HTML and press Format. Each tag is placed on its own line with nested elements indented so...
Developer ToolsCSS Minifier
Paste your CSS and the minifier removes comments and extra whitespace to make the file smaller, with the...
Developer ToolsJSON Formatter and Validator
Paste your JSON and the tool checks that it is valid, then formats it with indentation or compresses it...
Developer ToolsBase64 Encoder and Decoder
Base64 turns text or bytes into a safe string of letters and numbers. Choose encode or decode, paste...
Developer ToolsURL Encoder and Decoder
URL encoding replaces unsafe characters with a percent sign and two hex digits so a link works...
Developer ToolsPX to REM Converter
Convert pixel sizes to rem and em for responsive CSS, or turn rem values back into pixels, using...
Results are for information and education. For legal, financial, medical or security decisions, check with a qualified professional. Do not paste live secrets into any website.