Type a tool name, for example "keyword density" or "transcript".
Format and beautify minified or messy CSS code instantly in your browser.
A CSS formatter turns minified or messy stylesheets into clean, indented code you can read and edit. Paste your code into this free CSS formatter, choose 2 spaces, 4 spaces or tab indentation, and click Format / Beautify. You get a tidy version with one declaration per line, ready to copy into your project.
CSS formatting is the process of adding consistent line breaks and indentation to a stylesheet without changing what the rules do. Browsers ignore most whitespace in CSS, so a rule written on one line behaves exactly like the same rule spread over four lines. Formatting only changes how the code looks to you.
Minified CSS is the opposite. Build tools and CDNs strip spaces and line breaks to shrink file size, which leaves thousands of characters on one line. That helps page speed but makes debugging painful. A formatter restores the layout so you can see each selector, each declaration and each closing brace.
Formatting is not validation. A formatter rearranges layout, but it does not check that property names are spelled correctly or that values are legal. If a stylesheet misbehaves before formatting, it will usually misbehave afterward too, only now you can read it.
You can format a stylesheet in under a minute with the controls on this page. Follow these steps:
If you click the button with an empty box, the tool asks you to paste some CSS first. The input accepts up to 500,000 characters, which is far more than most single stylesheets contain. The Minify button does the reverse of formatting by collapsing line breaks and extra spaces, which is handy for a quick before-and-after comparison.
Here is a realistic case. You open a minified file from a CDN and see this single line of input:
body{margin:0;padding:0;font-family:sans-serif}.header{background:#333;color:#fff;padding:1rem}With 2 Spaces selected, the output becomes ten lines:
body{margin:0;, padding:0; and font-family:sans-serif}.header{background:#333;, color:#fff; and padding:1rem}Now you can see at a glance that the page body has no margin or padding and that the header uses a dark grey background with white text. Switch the menu to Tab or 4 Spaces and format again to see the same structure with deeper indents.
The formatter changes line breaks and indentation but keeps your own spacing inside a line. If your source already reads color: red; with a space after the colon, the space stays. If your source has none, the formatter does not add one. Runs of several spaces or line breaks are reduced to a single space.
A good formatted result has a predictable shape: a selector, an opening brace, indented declarations, then a closing brace aligned with the selector. Once your code looks like that, the indentation itself becomes a diagnostic.
Rules inside a media query or other at-rule are indented one level deeper than top-level rules. That is correct. If the last rules in your output are indented when they should sit at the left edge, a closing brace is probably missing somewhere above. Scroll up to the last block that looks normal and check the next one.
Anything inside parentheses stays on one line. That includes rgba(), calc(), var() and url() values, so a data URI containing semicolons will not be split apart. Strings in quotes and comments between slash-asterisk markers are also left alone, so your notes and content values survive.
Two spaces is a common convention in front-end projects and keeps deeply nested media queries narrow. Four spaces is easier to scan for some teams. Tabs let each developer set their own visual width in their editor. The best choice is whichever matches the rest of your repository, so your next commit does not show every line as changed.
After copying, load the page and confirm nothing moved. Since only whitespace changed, the page should look identical. If it does not, the difference was already in the original file.
Use a CSS formatter whenever you need to read or edit a stylesheet that was not written with readable layout. These situations come up often:
It also pairs well with other front-end tasks. Once your CSS is readable, you can add responsive rules with the CSS media query generator, or browse the full web developer tools collection for related utilities.
Most formatting problems come from pasting the wrong thing or expecting more than layout changes. These checks solve the common cases.
If the output looks odd, test with a small piece of the original. A stray quote mark or an unclosed comment can make the rest of the file behave as if it were part of that string or comment, so the layout stops changing partway through. Fixing that single character usually repairs everything after it.
The same approach works for other languages. The JavaScript formatter restores readable structure to scripts in the same way.
This tool is a layout formatter, not a linter or optimizer. It does not sort properties alphabetically, merge duplicate selectors, add vendor prefixes, remove unused rules or fix invalid syntax. It also keeps your spacing within a line, so it will not insert a space before an opening brace or after a colon if your source lacks one.
The Minify button collapses whitespace but is not a full compression pass. For the smallest file, use a dedicated minifier. Finally, rules are placed on consecutive lines without blank lines between them, so add spacing by hand if your style guide asks for it.
With those limits in mind, the formatter does one job well: it makes any stylesheet readable fast. Paste your CSS into the box above, pick your indentation and click Format / Beautify to see the clean version.
Your report has been submitted. We will look into this issue.
A VPN changes your network exit. It does not guarantee anonymity.
Themes, plugins, code, video, audio, graphics & more from 90,000+ authors.
Web Development
Design & Media
Unlimited Access
Explore Envato Market