ShotMark
Skip to Content

CSS Minifier

Minify CSS by removing whitespace and comments.

CSS
Minified
Waiting for input

What is CSS Minifier?

A CSS minifier is a tool that removes whitespace, comments, and redundant syntax from a CSS stylesheet to produce a smaller file that browsers parse and apply faster. The minified output is byte-for-byte different but renders identically to the original, since none of the trimmed characters affect the cascade or specificity.

Frontend developers, theme authors, and platform engineers run a CSS minifier on every production build. A 60 KB hand-authored stylesheet routinely drops below 18 KB after minification, and shrinks again to under 4 KB once gzip or Brotli compression kicks in.

Why use the CSS Minifier

  • Shrink stylesheets by 30% to 50%. Stripping whitespace, comments, and color shorthand alone removes a third of most hand-written CSS files.
  • Faster First Contentful Paint. Render-blocking CSS lives in the critical path. Smaller files mean shorter blocking time and better Core Web Vitals.
  • Lower CDN egress. Every byte saved compounds across thousands of pageviews. A 40 KB saving per visit adds up fast at scale.
  • Easier inline embedding. Critical CSS inlined into <style> blocks must stay under HTTP/2 header limits and one TCP packet for fastest delivery.

How to use the CSS Minifier

  1. Paste your stylesheet into the input panel on the left.
  2. Click the Minify button at the top of the panel.
  3. Read the minified result in the right panel. Syntax errors surface in red above the panels.
  4. Copy the output with the Copy button and paste it into your dist/styles.css, theme file, or inline <style> block.

What gets removed

The CSS minifier applies safe transformations only. No selector is renamed, no declaration is reordered, and the cascade is preserved.

PassActionTypical savings
Whitespace removalStrips newlines, indentation, spaces around {, }, :, ;25-35%
Comment strippingRemoves /* */ blocks including authoring notes5-15%
Trailing semicolonsDrops the last ; in each rule block1-2%
Color shorteningRewrites #ffffff to #fff, rgb(0,0,0) to #0001-3%
Zero unit collapseRewrites 0px, 0em, 0% to 00.5-2%
Quote normalizationDrops quotes around safe URL and font tokens0.5-1%

The tool does not merge duplicate selectors, reorder media queries, or rewrite shorthand properties. Those passes can change the cascade and break specificity-dependent styles.

Size savings example

Input (242 bytes):

/* Primary button styling */ .button-primary { background-color: #ffffff; color: #000000; padding: 0px 16px; margin-top: 0em; border: 1px solid #cccccc; }

Minified output (98 bytes):

.button-primary{background-color:#fff;color:#000;padding:0 16px;margin-top:0;border:1px solid #ccc}

Typical savings across input sizes:

InputRaw sizeMinifiedGzippedTotal reduction
Component styles2.4 KB1.1 KB540 B78%
Theme stylesheet35 KB14 KB3.8 KB89%
Framework reset + utilities120 KB48 KB11 KB91%
Tailwind production CSS350 KB110 KB28 KB92%

Common use cases

  • Production builds for marketing sites. Cuts critical CSS payload so the landing page paints in under one second on 4G.
  • Inline <style> for AMP and email. Both platforms enforce strict byte limits on inline styles. Minification keeps you under the cap.
  • WordPress and Shopify theme files. Most themes ship minified .min.css files alongside the source. The CSS minifier produces that file in one click.
  • Critical CSS extraction. After extracting above-the-fold rules with a tool like Critters, run the result through the minifier before inlining.

Frequently asked questions

Is minified CSS reversible?

Whitespace and comments cannot be restored once removed, since the information is gone. A CSS prettifier can re-indent the output for readability, but author comments and original formatting are lost forever. Keep your source files under version control.

Does minifying break my styles?

No, as long as the minifier sticks to safe transformations. The tool only removes characters the parser ignores. Specificity, cascade order, and inheritance behave identically. The single edge case is malformed CSS with missing semicolons, which the minifier will reject rather than silently fix.

What is the difference between minify and compress CSS?

Minification rewrites the stylesheet itself by removing characters, and the output is still valid CSS that any browser can parse directly. Compression (gzip, Brotli) wraps the byte stream in a binary encoding the server delivers and the browser decompresses. Both run together for maximum savings.

Should I minify CSS in development?

No. Minified CSS makes DevTools inspection harder, breaks source map line numbers in some setups, and hides authoring intent. Run the CSS minifier only as a production build step.

Will the minifier merge duplicate selectors?

Not by default. Merging duplicates can change cascade behavior when two rules with the same selector have different specificity contexts elsewhere in the file. The tool sticks to lossless transformations only.

Does minified CSS render faster?

Marginally at parse time, more meaningfully at transfer time. The browser’s CSS parser is fast either way, but smaller files arrive sooner over the network and unblock rendering earlier.

Can I minify CSS with custom properties or @container queries?

Yes. The minifier handles modern CSS including --variables, @container, @layer, nesting, and :has(). The output preserves the same syntax level as the input.

Will minification preserve license comments?

No, all comments are stripped by default. To keep a license header, prepend /*! (the bang comment) at the start of the file. Most minifiers preserve bang comments.

  • JavaScript Minifier - shrink JavaScript bundles by stripping whitespace and shortening identifiers.
  • HTML Minifier - collapse whitespace and remove comments from HTML markup.
  • SQL Minifier - flatten multi-line SQL into a single line for embedded queries.
  • CSS Prettify - re-indent minified CSS for inspection and code review.
Like this tool?

ShotMark captures what you do here, in one click.

The traces, payloads, and tests you run by hand? ShotMark grabs the whole bug and hands it to your AI agent.

Private beta accessFounding pricing lockNo spam ever