Format CSS Online Free — Beautify and Indent CSS Code Instantly
Table of Contents
CSS gets messy fast — especially when you're iterating quickly, patching styles directly in browser DevTools, or receiving code from a designer. Inconsistent spacing, single-line rules, and mixed formatting styles slow down every developer who touches the file.
This page covers how to format CSS online using our free browser-based CSS formatter, what gets cleaned up, and a few practical tips for keeping CSS readable.
What the CSS Formatter Cleans Up
The tool uses Prettier's CSS formatter to normalize your stylesheet. It handles:
- Property indentation — every property inside a rule block gets consistently indented
- Selector spacing — spaces before curly braces, after colons, and between selectors are normalized
- Rule separation — each CSS rule block gets a blank line between it and the next for readability
- Shorthand properties — Prettier may reorganize some shorthands for consistency
- Single-line to multi-line — rules collapsed to one line (common in minified CSS) are expanded
- Comments — comment formatting is normalized
The formatter does NOT sort properties alphabetically or by type (that's a separate tool/linter concern), and it does not remove vendor prefixes or optimize your CSS for performance. For compression, see the code minifier.
Does It Work With SCSS and Less?
The tool is configured for standard CSS. For SCSS (Sass), it will format the CSS-compatible parts correctly — regular selectors, properties, media queries. However, SCSS-specific syntax like $variables, @mixin, and nested rules may not format perfectly since those are outside the CSS spec.
For Less: same situation — standard CSS portions format fine, Less-specific syntax may be handled partially.
If you need full SCSS formatting, the best browser-based option is to run Prettier locally with the SCSS parser (prettier --parser scss), which is not available in this browser tool.
Expanding Minified CSS to Readable Format
One of the most common uses for the CSS formatter is reversing minification — taking compressed, single-line CSS and expanding it back to readable form.
For example, minified CSS looks like:
body{margin:0;padding:0;font-family:sans-serif}.header{display:flex;align-items:center;padding:16px 20px}
After formatting, it becomes a properly structured, multi-line stylesheet that you can read and edit.
Note: the formatter expands CSS — it does not reverse minification of class names or IDs. If you need to understand compressed CSS, formatting is the first step. If you also need to see the original source, a source map is the right tool.
Tab Width and Formatting Options for CSS
The CSS formatter respects the same options as the JavaScript and HTML formatters:
- Tab Width — 2 spaces is standard for CSS in most modern projects. 4 spaces is common in older codebases.
- Single vs double quotes — affects font-family strings and url() values. Most CSS style guides use double quotes.
- Print Width — controls when long selectors or property values wrap to a new line. 80 is standard.
If you're formatting CSS to match a team's existing style, match these settings to their project. Prettier's CSS output is deterministic — same input + same settings = same output every time.
Copying Formatted CSS Back to Your IDE
Once formatting is complete:
- Click the Copy button in the output box to copy the formatted CSS to your clipboard.
- Paste it directly into your CSS file in VS Code, WebStorm, or any editor.
- Optionally click Download to save it as a .css file.
For teams using VS Code with Prettier installed: once you have a consistent formatting baseline from this tool, set up format-on-save in VS Code so future edits stay consistent automatically. See our VS Code Prettier setup guide.
Format Your CSS Now — Free, No Signup
Clean up any CSS file in seconds. Runs in your browser — no install, no account needed.
Open Free Code FormatterFrequently Asked Questions
Will it sort my CSS properties?
No. Prettier does not sort properties — it normalizes spacing and structure only. CSS property ordering is a style preference that varies between teams. Tools like Stylelint with the order plugin handle that.
Can it format CSS-in-JS?
No. CSS-in-JS (template literals in styled-components, emotion) requires the JavaScript formatter with the styled-components plugin. This tool formats standalone .css files only.
Does it handle media queries and keyframes?
Yes. @media rules, @keyframes, @supports, and other at-rules are all handled correctly by the Prettier CSS parser.
Is minified Tailwind output safe to paste?
Yes for formatting purposes — it will expand it. However, Tailwind utility classes are meant to be minified and rebuilt by the Tailwind CLI, so formatting minified Tailwind output is mainly useful for reading, not for editing.

