CODDY Tool

CSS Formatter

Format or minify CSS without corrupting strings and data URIs.

Tidy messy CSS into consistent indentation, or minify it for production. Parses the stylesheet properly, so semicolons inside data URIs and braces inside content strings survive intact.

Everything you enter stays in this browser tab. Nothing is sent to our servers, logged or stored.

Loading tool…

What CSS Formatter supports

  • FormatConsistent indentation.
  • MinifySmallest safe output.

About CSS Formatter

Formatting CSS looks like a job for a regular expression, and that is why so many online minifiers quietly break stylesheets. The characters that give CSS its structure — braces, semicolons, comment markers — are only structural at the top level. Inside a string or a url() they are ordinary text.

Two constructs get destroyed by the naive approach. A background image written as an inline data URI contains semicolons: url(data:image/svg+xml;base64,…). Split on those and the declaration is truncated. A content property can legitimately contain braces: content: "a; b { c }". Split on those and the block structure collapses. Both produce output that looks plausible and is broken.

This tokenises the stylesheet instead, tracking whether it is inside a string, a comment or a url() before treating any character as structure. The tests cover both cases directly, because they are the ones that matter.

How to format CSS

  1. Paste your CSS

    Any size. It is parsed in your browser and never uploaded.

  2. Choose format or minify

    Formatting sets consistent indentation; minifying strips everything not needed to render.

  3. Copy or download

    The statistics show how much minifying would save before you commit to it.

What minifying actually removes

  • Comments, entirely. Keep a licence header in a separate file if you need one.
  • Whitespace between tokens, and the final semicolon in each block, which is optional.
  • Units on zero lengths — 0px becomes 0. Time units are left alone, because 0s is not always interchangeable with 0.
  • Six-digit hex colours become three digits when the pairs repeat, so #ffffff becomes #fff but #4a49d8 is untouched.
  • Percentages in keyframe selectors are never touched, because 0% there is a selector rather than a value.

Frequently asked questions

Will minifying break my CSS?

Not here. The common breakages come from regex-based tools splitting on a semicolon inside a data URI or a brace inside a content string. This parses the stylesheet, so both survive — and there are tests for exactly those cases.

How much smaller will my CSS get?

Typically 20–40% for hand-written CSS with comments and generous whitespace, less for output that a build tool has already processed. The statistics show the real figure for your file before you copy anything.

Does minified CSS load faster?

A little, though gzip or brotli compression already removes most of the redundancy that minifying targets. The gain is real but smaller than the raw byte difference suggests, because compressed transfer is what actually crosses the network.

Is my stylesheet uploaded?

No. Parsing and output both happen in this browser tab, which matters if the CSS belongs to an unreleased project.

All Developer Tools

CSS Formatter is free to use with no account, no watermark and no usage limits. Last updated 14 August 2026.