CSS Formatter & Minifier

Beautify messy CSS with proper indentation, or minify for production.

Input
Output

Free Online CSS Formatter

Paste any CSS code — minified, messy, or copy-pasted from browser DevTools — and get clean, properly indented output. The formatter handles real-world CSS including nested @media queries, @keyframes, custom properties, and complex selectors.

Format or Minify

The formatter adds consistent 2-space indentation, line breaks after each property, and proper spacing around braces and colons. The minifier strips all unnecessary characters, removing comments and whitespace while preserving string contents.

How It Works

The CSS formatter uses a character-by-character state machine that tracks nesting depth, string boundaries, and comment blocks. Unlike regex-based formatters, this approach correctly handles edge cases like URLs containing special characters and nested at-rules.

Related Tools

Format your HTML alongside CSS with our HTML Formatter, or use the JavaScript Formatter for your scripts. Generate SEO-ready meta tags with the Meta Tag Generator.