DEVELOPER PRECISION ENGINE

CSS Formatter / Minifier

Format or minify CSS code. Four previously-confirmed bugs are now fixed: the opening brace now sits on the same line as its selector (.a { style, matching Google/Airbnb convention), rules nested inside @media/@supports get indented to genuinely match their real depth, a rule's final property is now indented correctly even with no trailing semicolon, and Minify no longer collapses meaningful whitespace inside quoted content: "..." string values.

How to Use This Tool

1

Paste your CSS code into the input textarea.

Paste your CSS code into the input textarea.

2

Click "Format" to beautify with indentation

the selector and its opening brace now stay on the same line, matching conventional CSS style.

Pro Tip

Minifying CSS before every production deploy is one of the highest-leverage, lowest-effort performance wins available — cutting real bandwidth for every visitor with no risk to how a rule's selectors or standard declarations behave. A content: "..." value with intentional multiple spaces (used for spacing tricks in ::before/::after pseudo-elements) is now safe to minify without manually checking it afterward, since that whitespace is preserved exactly rather than collapsed.

About This Tool

When to Use

  • Cleaning up auto-generated CSS from Tailwind, Bootstrap, or a CMS export before manual editing, now with output that matches conventional same-line-brace style.
  • Minifying a stylesheet immediately before a production deploy to cut page load weight
  • Reviewing and editing legacy CSS that has no consistent formatting convention across the file.

Key Details

A CSS formatter takes CSS with inconsistent or missing formatting and reformats it with each declaration indented within its rule block and consistent spacing, so a dense or auto-generated stylesheet ...

Worked example

Someone pastes the tool's own previously-cited example input: .a{color:red}.b{background:blue}. Running that exact string through the real formatter now produces: .a {, then color:red; indented one level, then }, then .b {, then background:blue; indented one level, then } — brace on the selector's own line and the single property correctly indented in both rules, even though neither has a trailing semicolon in the source. A nested example, @media (max-width: 600px) { body { color: red; } }, now formats with body { indented one level under the @media selector and color: red; indented two levels, both correctly reflecting their real nesting depth.

Interpreting your result

Trust the formatted output's brace placement, nested-rule indentation, and last-property indentation — all four previously-confirmed layout bugs are fixed and verified against the tool's own previously-cited examples plus additional nested and edge-case inputs. Rule and selector counts, and size figures for original/formatted/minified versions, remain accurate as before. Minified output now preserves quoted content: "..." string values exactly, including any meaningful internal spacing.

CSS Formatter / Minifier FAQ

What does the CSS formatter do, and where does the opening brace go?

It takes CSS with inconsistent formatting and reformats it with properties indented within their blocks and consistent spacing, making large stylesheets easier to scan. The selector and its opening brace are placed on the same line — .a { color: red; } style, matching the convention used by most CSS style guides (Google, Airbnb) and most hand-written CSS. This was previously a confirmed bug (brace pushed to its own separate line below the selector) and has since been fixed.

Are @media queries and @keyframes supported, with proper nested indentation?

Yes. At-rules like @media, @keyframes, and @font-face are recognized, and both the properties inside their nested rules AND the nested rule's own selector line and opening brace get indentation reflecting their real depth — a rule nested inside @media now visually shows that nesting, not just its properties. This was previously a confirmed bug (the nested selector and brace stayed flush against the left margin regardless of depth) and has since been fixed.

Does formatting always indent the last property in a rule correctly?

Yes. A rule's final property is indented correctly whether or not it has a trailing semicolon before the closing brace — including in compact or minified CSS with no trailing semicolons, which is a common input for a formatter like this. This was previously a confirmed bug (the last property lost its indentation when there was no trailing semicolon, because the nesting depth was decremented before that property was indented) and has since been fixed.

What is CSS minification, and is it fully safe to use?

CSS minification removes comments and collapses whitespace between selectors, declarations, and punctuation to shrink file size — safe for the vast majority of real CSS, since minification is meant to be purely a whitespace change. Whitespace inside a quoted content: "..." string value (used with ::before/::after pseudo-elements) is now correctly preserved exactly as written — content: "a b" stays content: "a b" after minifying, rather than collapsing to a single space. This was previously a confirmed bug (quoted string content was minified the same as everywhere else, silently changing what rendered on the page) and has since been fixed by protecting quoted string content from the minification pass entirely.

Can this combine multiple CSS files?

No, this tool processes one CSS input at a time. For combining multiple files, concatenate them before pasting. The formatter will process all rules across the combined input.

Are CSS custom properties (variables) preserved during formatting?

Yes. CSS custom properties (--variable-name: value) are treated as standard declarations and preserved exactly, confirmed via code read — there's no special-case logic that would drop or alter them. Properties defined in :root for global scope, and those scoped to selectors, are formatted the same way as any other declaration (subject to the indentation caveats described above), and the output remains valid, standard CSS.

Master Your Entire Toolkit

Access 500+ specialized calculators and tools designed for precision. No sign-up required, 100% free.

Built and reviewed by the Toolzip Team · Based on W3C CSS Specification