Local stylesheet utility

CSS Minifier

Shrink CSS without treating strings, URLs, escapes, or custom-property values as ordinary text. Choose conservative cleanup or two narrowly proven extras, then inspect exact UTF-8 savings.

Private by design: CSS stays in this browser tab. This tool does not fetch imports or URLs, upload code, save history, or send input to an API.

CSS input

Maximum 250,000 UTF-16 code units and 64 combined nested blocks. Keep your readable source as the canonical project file and treat minified CSS as a generated artifact.

Extras remove a verified final declaration semicolon and allowlisted zero length units outside functions. They never alter custom-property values.

Minified CSS

No result yet. Minify and test the output in its real project context before publishing.

0 BInput UTF-8
0 BOutput UTF-8
0 BBytes saved
0%Reduction

Run the minifier to see what was removed and what was deliberately protected.

What this CSS minifier changes

Safe cleanup removes comments only at safe boundaries, collapses formatting whitespace, and removes whitespace beside braces, commas, semicolons, and verified declaration colons. It preserves source order, selectors, at-rules, property/value spelling, quoted strings, url() contents, escapes, and unknown syntax. A comment between tokens is retained when deleting it could fuse those tokens.

Safe + proven extras also removes the last semicolon only from a straightforward non-custom declaration immediately before its closing brace. It converts zero length dimensions to 0 only for an explicit set of box, size, inset, border-width, radius, outline, and gap properties, and never inside a function. It does not rewrite zero percentages, angles, times, flex units, or custom values.

Why strings, URLs, escapes, and variables need care

The characters in content: "/* not a comment */" are string data. Data URLs can contain punctuation that resembles CSS structure. A hexadecimal escape can consume following hexadecimal characters unless its terminator whitespace is retained. The scanner therefore preserves these representations instead of running comment and whitespace regular expressions over the whole file.

Custom properties are token streams substituted later by var(). This tool preserves everything after a detected --name: through the declaration terminator, including repeated whitespace and comments. A declaration whose property name contains an escape receives the same conservative treatment because the escaped spelling could denote a custom property. That costs bytes but avoids changing a value whose eventual grammar is unknown.

Validation scope and production use

The scanner rejects NUL, unpaired Unicode surrogates, unfinished comments/strings/URLs/escapes, escaped function names, more than 64 combined nested blocks, and unbalanced braces, brackets, or parentheses. Escaped function names are rejected because an escaped spelling of url would otherwise require URL-token handling after escape decoding. This is not a complete CSS grammar validator: an unknown property, unsupported selector, misspelled value, browser-recovered error, or context-sensitive nesting problem may still pass through unchanged.

Always retain the readable original, review the generated diff, and test important pages, states, breakpoints, animations, and target browsers. Minification reduces source bytes; HTTP gzip or Brotli can reduce transfer size further, so the displayed UTF-8 savings are not a transfer-size prediction.

Standards and privacy

The conservative behavior follows the token and representation concerns in the CSS Syntax specification, the value grammar in CSS Values and Units, and the preservation requirements in CSS Custom Properties. Input, output, copying, and file creation remain local to this page; the tool adds no request, tracking, storage, cookie, session, or database operation.