ToolNimba

๐ŸŽจ CSS Minifier: Minify and Compress CSS Online Free

Shihab Mia By Shihab Mia ยท Updated 2026-07-05

Minified CSS
 
Paste CSS above, then press Minify CSS to see the savings.

A CSS minifier shrinks your stylesheet by deleting every character a browser does not need to render the page: comments, line breaks, indentation, and the spaces around braces, colons, semicolons, and commas. Paste your CSS, press Minify, and you get one compact block plus a readout of the original size, the minified size, and the percentage you saved. Everything runs in your browser, so your code is never uploaded anywhere. Most hand-written stylesheets shrink by 20 to 50 percent before any server compression is even applied.

What is the CSS Minifier?

Minification is the process of stripping characters that exist only for human readability and have no effect on how a stylesheet behaves. A browser does not care whether a rule sits on one line or twenty, or whether there is a space after a colon. Those characters still cost bytes, and bytes cost download time. By removing comments, collapsing every run of whitespace down to nothing or a single required space, and deleting the spaces around structural punctuation such as braces, the colon, the semicolon, and the comma, a CSS minifier can often cut a hand-written stylesheet by 20 to 50 percent before any further compression is applied.

Smaller CSS matters for page speed and for Core Web Vitals. CSS is render-blocking, which means the browser will not paint the page until it has downloaded and parsed the stylesheets referenced in the head. The fewer bytes it has to fetch, the sooner the first paint can happen, especially on slow mobile connections. This directly influences Largest Contentful Paint, one of Google's Core Web Vitals ranking signals, because the main content cannot appear until the render-blocking CSS is out of the way.

Minification and server compression are two different steps that stack. A minifier removes redundant characters from the file itself, while Gzip or Brotli compress whatever bytes remain as they travel over the network. Because a minified file is already free of the repetitive whitespace that a compressor would otherwise have to encode, the two techniques compound: the transferred size drops further when you minify first and let the server compress on top. You should always do both, not one or the other.

This tool performs safe, structural minification only. It does not rename your classes, reorder declarations, merge duplicate rules, or rewrite color values, because those transformations can change behaviour, cascade order, or specificity in subtle ways. It sticks to the changes that are always safe: dropping comments unless you ask to keep them, removing redundant whitespace, and deleting the final semicolon before a closing brace. The output is byte-for-byte equivalent CSS that a browser parses exactly as it did your original file.

Minification is lossless for behaviour but not reversible for readability. Once whitespace and comments are gone, you cannot recover your indentation or your notes automatically, so the minified file is a build artefact, not something you edit by hand. The professional workflow is to keep a readable source file, run it through a minifier as part of your build or deploy step, and ship only the compact result. When you need to debug minified CSS in production, browser DevTools and CSS source maps let you map the compact output back to your original source lines.

When to use it

  • Shrinking a production stylesheet before deploying a static site, theme, or landing page.
  • Cleaning up CSS copied from a tutorial, framework, or generator so it pastes compactly into a project.
  • Reducing the size of inline critical CSS placed in the head of a document for faster first paint.
  • Measuring how much weight a stylesheet carries by comparing the original and minified byte counts.
  • Cutting render-blocking bytes to improve Largest Contentful Paint and PageSpeed Insights scores.
  • Preparing CSS for an email template or embedded widget where every byte of payload counts.

How to use the CSS Minifier

  1. Paste or type your CSS into the input box.
  2. Leave Keep comments unchecked to strip them, or tick it to preserve a license banner.
  3. Press Minify CSS to generate the compact output.
  4. Read the size summary to see the bytes and percentage saved.
  5. Press Copy to put the minified CSS on your clipboard, then paste it into your build.

Formula & method

saved% = (originalBytes - minifiedBytes) / originalBytes * 100. Bytes are measured as UTF-8 encoded length, the same way a server reports file size, so a multi-byte character such as an accented letter counts as more than one byte.
How CSS Minification Shrinks a StylesheetOriginal CSS (44 bytes)/* main */body { margin: 0; color: #fff ;}minifystrip commentscollapse spacesMinified CSS (25 bytes)body{margin:0;color:#fff}Saved 19 bytes, about 43 percent smallerThen Gzip or Brotli compression shrinks it further in transit

Worked examples

A small rule with a comment, extra spaces, and a trailing semicolon.

  1. Input: /* main */ body { margin: 0; color: #fff ; }
  2. Remove the comment block /* main */
  3. Collapse whitespace and remove the spaces around { } : ;
  4. Drop the trailing semicolon before the closing brace
  5. Output: body{margin:0;color:#fff}

Result: From 44 bytes down to 25 bytes, a saving of about 43 percent.

Two selectors sharing a block with padded spacing.

  1. Input: .box , .card { padding: 10px 20px ; }
  2. Collapse the spaces around the comma and the braces
  3. Remove the space before the trailing semicolon, then drop that semicolon
  4. Preserve the single space inside the value 10px 20px, since it separates two lengths
  5. Output: .box,.card{padding:10px 20px}

Result: The selector list and shorthand value stay valid while every redundant space is removed.

A media query with nested indentation.

  1. Input: @media (min-width: 768px) {\n .nav {\n display: flex;\n }\n}
  2. Remove the newlines and indentation inside and around the query
  3. Keep the single space in min-width: 768px inside the parentheses where the grammar needs it
  4. Collapse the spaces around the braces and the colon in the declaration
  5. Output: @media (min-width:768px){.nav{display:flex}}

Result: The at-rule condition and nested rule are preserved exactly while all layout whitespace disappears.

What CSS minification removes and what it keeps

Character or tokenActionWhy
Block comments /* ... */Removed by defaultComments never affect rendering
Line breaks and indentationRemovedWhitespace between tokens is optional
Spaces around braces, colon, semicolon, commaRemovedNot required by the CSS grammar
Trailing semicolon before }RemovedThe last declaration does not need one
Single space inside a value (10px 20px)KeptIt separates two distinct values
Space in a selector combinator (.a .b)KeptThe descendant combinator is a space

Typical size reduction by input type

InputWhitespace levelTypical minified saving
Hand-written, well indented CSSHigh30 to 50 percent
CSS from a build tool (already compact)Low5 to 15 percent
Framework CSS with license commentsMedium15 to 30 percent
Already minified fileNoneNear 0 percent

Minification versus other CSS optimizations

TechniqueWhat it doesSafe automatically
MinificationRemoves whitespace and commentsYes, structural only
Gzip or BrotliCompresses bytes in transitYes, server side
Dead CSS removalDeletes unused selectorsNo, needs coverage analysis
Rule mergingCombines duplicate declarationsNo, can shift the cascade

Common mistakes to avoid

  • Minifying the file you also edit. Always keep your readable source file and minify a copy for production. Editing minified CSS by hand is painful and error prone, so treat the minified output as a build artefact, not your master file.
  • Stripping comments that carry a license. Some libraries require their license banner to stay in the file. If your CSS includes a legal notice, tick Keep comments so the banner is preserved rather than removed.
  • Expecting minification to fix invalid CSS. A minifier only removes redundant characters, it does not repair broken syntax. If a brace is missing or a property is misspelled, the minified output will carry the same error forward unchanged.
  • Assuming minified equals fully optimized. This tool removes whitespace and comments but does not merge duplicate rules, drop unused selectors, or shorten color values. For deeper optimization, also remove dead CSS and let your server apply Gzip or Brotli.
  • Removing the space in a descendant combinator. The space in a selector like .menu .item is the descendant combinator and is meaningful. A correct minifier keeps it, because collapsing it to .menu.item would target a completely different element.
  • Skipping server compression after minifying. Minification alone leaves gains on the table. Without Gzip or Brotli enabled on the server, visitors still download more bytes than they need. Do both steps, since they stack rather than replace each other.

Glossary

Minification
Removing characters that are not needed for a browser to parse and render code, such as whitespace and comments, without changing behaviour.
Whitespace
Spaces, tabs, and line breaks. In CSS most whitespace between tokens is optional and can be removed safely.
Render-blocking
A resource the browser must download and parse before it can paint the page. CSS referenced in the head is render-blocking by default.
Gzip and Brotli
Compression methods a web server applies to shrink files in transit. They work best on already minified files.
Critical CSS
The small subset of CSS needed to style content visible on first load, often inlined in the head for faster first paint.
Core Web Vitals
Google's set of user-experience metrics, including Largest Contentful Paint, used as a page ranking signal.
Source map
A file that maps minified output back to the original source lines so you can debug compact CSS in DevTools.
Combinator
A character such as a space, >, +, or ~ in a selector that defines the relationship between the elements it joins.

Frequently asked questions

What does a CSS minifier do?

A CSS minifier removes characters a browser does not need, including comments, line breaks, indentation, and the spaces around braces, colons, semicolons, and commas. The result is a smaller file that renders exactly the same as your original CSS but downloads faster.

Does minifying CSS change how my site looks?

No. Safe minification only strips redundant whitespace and comments and the optional trailing semicolon. It does not touch your selectors, properties, or values, so the browser parses the minified CSS identically to the original and the visual result is unchanged.

How much smaller will my CSS get?

It depends on how much whitespace and commenting the original file has. Hand-written, well-indented CSS often shrinks by 20 to 50 percent, while an already-compact build output may only drop a few percent. The tool shows the exact byte count and percentage saved after you minify.

How do I minify CSS online for free?

Paste your CSS into the input box above and press Minify CSS. The tool instantly removes comments and whitespace, shows how many bytes you saved, and lets you copy the compact output. It is free, runs in your browser, and requires no signup or upload.

Can I keep my comments when minifying?

Yes. Tick the Keep comments box before pressing Minify. This is useful when a stylesheet includes a license banner that must remain in the file. Whitespace is still collapsed around the comment, so you keep the notice while still shrinking the file.

Is my CSS uploaded to a server?

No. The minifier runs entirely in your browser using plain JavaScript. Your CSS never leaves your device, which makes it safe to use with private, unreleased, or proprietary stylesheets.

What is the difference between minifying and compressing CSS?

Minifying rewrites the file to remove whitespace and comments, so the file itself is smaller. Compressing with Gzip or Brotli encodes whatever bytes remain as they travel over the network. They stack: minify first, then let the server compress, and the transferred size drops further than with either step alone.

Should I still compress minified CSS on my server?

Yes. Minification and server compression work together rather than replacing each other. Minified CSS is already free of repetitive whitespace, and applying Gzip or Brotli on top shrinks the transferred size even more for visitors. Enable both for the best result.

Can I un-minify or reverse minified CSS?

You can re-indent minified CSS with a formatter or beautifier to make it readable again, but you cannot recover the original comments or your exact formatting, because that information was deleted. This is why you should always keep your readable source file rather than editing the minified version.

Will minifying CSS improve my Core Web Vitals or SEO?

It can help. CSS is render-blocking, so fewer bytes mean the browser can paint content sooner, which improves Largest Contentful Paint, one of Google's Core Web Vitals ranking signals. Minification is one of several speed optimizations, so pair it with server compression and dead-CSS removal for the biggest gain.