About the CSS Formatter
Minified stylesheets from themes, plugins and production sites are almost impossible to read or debug. This CSS formatter expands them into a consistent layout: one selector per line, one declaration per line, a space after each colon and a semicolon after every declaration, with media queries, keyframes and other at-rules indented correctly and comments preserved. Uniform formatting makes it far easier to find a rule, compare versions of a stylesheet and review changes from teammates. Strings and URLs are left exactly as written, and the tool works entirely in your browser. When you are done editing, shrink the file again with the CSS Minifier, and for interactive experiments try the Live HTML Editor.
Responsive stylesheets are built from layers of nesting, and that nesting is what the formatter makes visible. Anything inside a media query, a supports block, a keyframes rule or a cascade layer is pushed one indent deeper than its parent, so you can scroll through a long file and see at once which rules apply at which screen size. Comments stay exactly where they were written; a note that drifts away from the rule it describes is more misleading than no note at all.
Only the spacing changes. Selectors keep their order and their specificity, every value is kept character for character, and no property is moved, so the expanded file applies exactly the same styles as the compressed one. That also keeps version control honest: compare the two copies and the only differences you will find are line breaks and indentation.
How to use the CSS Formatter
- Paste the stylesheetDrop in a minified production file, a theme stylesheet or rules you wrote yourself; any of them works.
- Pick the indentationUse two spaces, four spaces or a tab, whichever matches the rest of your project.
- Run FormatThe expanded CSS appears under the input, one declaration on each line.
- Take the resultCopy it to the clipboard or download it as a .css file.
CSS Formatter features
- Each selector and each declaration placed on its own line
- Nested indentation for @media, @supports, @keyframes and @layer
- Comments left where they were written
- A semicolon added after the last declaration in every block
- Even spacing around colons, commas and braces
- Property order and values never touched
- Warns about braces that are not balanced
- Copy or download the formatted file
Common uses
- Opening up a compressed stylesheet from a live website to study it
- Bringing CSS written by several people into one consistent layout
- Getting a clean, readable diff between two versions of a stylesheet
- Tracking down the missing brace that disabled half a stylesheet
- Tidying CSS before a teammate reviews it
Formatting CSS in practice: fixing a theme bug, source maps, unused rules, specificity battles, property order and old prefixes
Formatted CSS is the starting point for understanding a stylesheet someone else wrote, whether that is a minified theme file, a plugin's styles or a legacy project. This guide uses formatting to track down a mobile styling bug in a WordPress theme, then covers source maps, finding unused rules, untangling specificity, ordering properties, removing outdated prefixes and styles for right-to-left Urdu pages.
A worked example: a button colour that changes on phones
A theme's buttons appear green on desktop but grey on phones. The theme ships a minified stylesheet, so the site owner copies it, formats it and searches for the button's class. Inside a media query for small screens, a rule from an old theme option overrides the colour. Instead of editing the theme's file, which an update would overwrite, the fix goes into the child theme's stylesheet or the customiser's additional CSS.
Source maps first
If a site publishes source maps, the browser's developer tools show the original, unminified source files and line numbers automatically. Check for them before formatting anything. Formatting is the fallback when no source maps exist, which is common with themes and plugins downloaded as finished packages.
Finding unused rules
Formatted stylesheets make repeated and unused rules easier to spot. The Coverage panel in Chrome's developer tools shows which CSS was actually used while you browse a page. Combining that information with a readable stylesheet helps remove dead rules safely, reducing file size for every visitor.
Specificity battles
Long chains of overrides, each more specific than the last and often ending in !important, are much easier to see in formatted CSS. Untangling them, by reducing selector specificity and removing unnecessary !important flags, makes future changes predictable instead of an ever-escalating fight between rules.
Property order
Some teams order properties consistently, for example positioning first, then box model, then typography and finally visual effects. The formatter preserves whatever order exists, while linting tools can enforce an agreed order automatically. Any consistent order makes rules faster to scan than random placement.
Outdated prefixes
Older stylesheets are full of prefixes such as -webkit-border-radius and -moz-box-shadow that modern browsers no longer need. Build tools that add prefixes based on the browsers you support can remove the obsolete ones. Deleting them by hand after formatting is also safe for well-established properties, but test in Safari, which still needs a few prefixes.
Styles for Urdu pages
Sites offering Urdu pages need styles that mirror for right-to-left text. Logical properties, such as margin-inline-start instead of margin-left, adapt automatically to the page direction. For older stylesheets written with left and right, tools exist that generate a mirrored right-to-left version, and formatted CSS makes it easier to check what they changed.
Keeping source readable
Commit readable, formatted CSS to version control and generate minified files during deployment. Reviewing changes in formatted files is straightforward, whereas a one-line minified file turns every change into an unreadable diff. If a project has no build step, keeping both versions side by side, clearly named, is a reasonable compromise.
Common mistakes
- Editing a theme's minified file instead of a child theme.
- Formatting when source maps would show the original files.
- Escalating specificity with more !important flags.
- Keeping obsolete vendor prefixes indefinitely.
Related tools
To minify the finished stylesheet, use CSS Minifier. To convert pixel values while tidying, try PX to REM Converter, and to convert colours between formats, Color Converter.
Custom properties at the top
Collecting design values such as colours, spacing and font sizes as custom properties in a :root rule near the top of the stylesheet makes them easy to find and change. Formatting an older stylesheet often reveals the same hex value repeated dozens of times, which is a clear sign it should become a variable.
Consolidating near-duplicate colours
Searching formatted CSS for colour codes often reveals near-duplicates, such as #333333, #343434 and #323232, added by different people over time. Replacing them with a small, deliberate palette makes the design more consistent and the stylesheet easier to maintain, and visitors are unlikely to notice anything except a tidier look.
Splitting and layering large stylesheets
Very long stylesheets become easier to manage when split into sections for base styles, layout, components and utilities. Cascade layers, declared with @layer, let you decide which section wins when rules conflict, regardless of selector specificity, which reduces the need for !important in growing projects.
Print styles
Search the formatted file for an @media print block. If there is none, adding one that hides navigation, ads and buttons, uses black text on white and shows link addresses after links makes printed pages such as receipts, recipes and articles far more useful.
Reviewing third-party styles
Plugins and widgets often add their own stylesheets. Formatting them before adding overrides shows which selectors they use and how specific those are, so your overrides can match them precisely rather than resorting to !important, and you can spot plugins that load far more CSS than they need.
Privacy
Formatting runs in your browser. Your stylesheets are not uploaded or stored.
Frequently asked questions
Will my styles look any different after formatting?
They will not. The formatter only adds line breaks and indentation, while selectors, their order, their specificity and every value stay as you wrote them, so the browser applies identical rules.
Does the formatter remove or move my comments?
Neither. Each comment is kept in its original position, because comments usually record why a rule exists, and that reasoning is lost for good once a tool deletes it or shifts it elsewhere.
How does it lay out media queries and other at-rules?
The at-rule sits on its own line and everything inside it is indented one level further than the rule itself. Media queries, supports blocks, keyframes and layers all follow that pattern, so their contents are easy to see.
What if my CSS has an unbalanced brace?
You get a warning instead of a silent guess. One missing or extra brace can make the browser ignore every rule after it, so locating that brace is often the real reason for formatting the file.
Can it merge duplicate properties or convert them to shorthand?
No. Combining declarations or switching to shorthand can change which value wins depending on context, so those edits stay your decision and the formatter limits itself to whitespace.
Is my stylesheet sent to a server?
No, your CSS never leaves the device. The formatting is done by JavaScript inside this page, so unreleased themes and client stylesheets can be pasted without being uploaded anywhere.