User Rating 0.0 β˜…β˜…β˜…β˜…β˜…
Total Usage 0 times
Category CSS Tools
Input CSS
Output
Input: 0 chars | Output: 0 chars, 0 lines | Depth check: —
Is this tool helpful?

Your feedback helps us improve.

β˜… β˜… β˜… β˜… β˜…

About

Minified CSS reduces file size for production but makes debugging and auditing nearly impossible. A single missing semicolon in a 40,000-character one-liner can cost hours of manual tracing. This tool parses raw CSS character-by-character, reconstructs proper nesting hierarchy, and outputs cleanly indented code with consistent brace placement. It handles nested at-rules (@media, @keyframes, @supports), preserves string literals and url() references, and respects comment blocks without mangling their content.

The formatter does not validate CSS syntax. It operates as a whitespace and newline normalizer that relies on bracket-depth tracking. Malformed input with unbalanced braces will produce indentation drift proportional to the mismatch count. For critical stylesheets, pair this tool with a linter. Pro tip: always prettify vendor CSS before code review to surface overrides and specificity conflicts hidden in compressed output.

css prettify css formatter css beautifier format css css indent css code formatter prettify css online

Formulas

CSS prettification is a deterministic text transformation. The formatter uses a depth counter d that increments on { and decrements on }. Each line’s leading whitespace equals:

indent = charsize Γ— d

Where char is the chosen indent character (space or tab), size is the configured indent width, and d is the current bracket depth. The tokenizer state machine recognizes five contexts: normal, comment, single-quote string, double-quote string, and url-parens. Inside string or url contexts, all characters pass through unmodified. In normal context, the formatter applies these rules in order:

{
newline + indent(d) after {newline + indent(d) after ;newline + indent(d) before }collapse(whitespace) otherwise

For selector-per-line mode, commas outside of value contexts trigger a newline. The algorithm is O(n) where n is the character count of the input.

Reference Data

OptionValuesDefaultEffect
Indent CharacterSpaces / TabsSpacesControls the whitespace character used for each indent level
Indent Size1 - 82Number of indent characters per nesting level
Opening BraceSame Line / New LineSame LinePlaces { on the selector line or the next line
Blank Line Between RulesYes / NoYesInserts an empty line between top-level rule blocks
Selector Per LineYes / NoYesSplits comma-separated selectors onto individual lines
Align ColonsYes / NoNoPads property names so colons align within a block
CSS MinificationStandard - Removes all optional whitespace and comments
Comment HandlingPreserve / StripPreserveKeeps or removes /* … */ blocks
Max Line LengthUnlimited∞Formatter does not wrap long values; manual wrap required
Trailing SemicolonAlwaysAlwaysEnsures last declaration in a block ends with ;
@media NestingSupported - Correctly indents rules inside nested at-rules
@keyframesSupported - Formats percentage selectors and their declarations
@font-faceSupported - Treats as standard block with property declarations
@import / @charsetSupported - Preserved on individual lines at document top
String PreservationAlways - Content inside quotes is never modified
url() PreservationAlways - Paths inside url() are never modified

Frequently Asked Questions

No. The formatter only modifies whitespace characters (spaces, tabs, newlines) and optionally strips comments. Property names, values, selectors, and the order of declarations remain identical. The output is semantically equivalent to the input.
The depth counter d is clamped to a minimum of 0. If a closing brace appears without a matching opener, the indentation simply stays at zero rather than going negative. However, missing closing braces will cause all subsequent rules to be indented one level too deep. The output footer reports if the final depth is not zero, indicating a brace mismatch.
Yes. Custom properties (--my-color), calc(), var(), clamp(), nesting (CSS Nesting Module), and @layer are all treated correctly because the formatter operates at the character/token level, not against a fixed grammar. Any valid bracket-delimited block is indented.
The formatter runs in the main thread with O(n) complexity. Inputs up to approximately 2 - 3 MB of CSS (roughly 50,000 - 100,000 lines when formatted) process in under 500 ms on modern hardware. Beyond that, the UI may briefly freeze. For production-scale formatting of massive bundles, a CLI tool like Prettier is more appropriate.
Yes. Enable the Minify toggle to strip all comments, collapse whitespace to the minimum required, and output a single-line result. This is a basic safe minification that does not perform value-level optimizations (e.g., shortening #ffffff to #fff). For aggressive optimization, use a dedicated minifier like cssnano.
Each formatter has its own opinion on brace placement, blank lines, and property ordering. This tool provides configurable options for the most common preferences but does not reorder properties or enforce alphabetical sorting. The goal is structural clarity through indentation, not style enforcement.