πŸ“¦

CSS Minifier

βœ“ Free & no signup πŸ”’ Runs 100% in your browser Updated 2026-11-25 Website Management Tools

CSS carries more removable bytes than most people expect. Every declaration indented on its own line, every comment explaining why a hack exists, every trailing semicolon before a closing brace: none of it changes how a single pixel renders. A minifier strips all of it, and this tool does the pass live in your browser, showing the before and after byte counts so the saving is a measurement rather than a guess.

Paste your stylesheet and the compacted result appears immediately. Three transformations are applied: comments are removed, all unnecessary whitespace including indentation and line breaks is stripped, and the last semicolon before each closing brace is dropped because it is optional in CSS grammar. Selectors, properties, values, and at-rule structure are untouched, so the minified file behaves identically to the original.

The tool runs locally; stylesheets with private design tokens, internal class conventions, or unreleased client themes never leave your device. There is no signup and no cost, and the page works on mobile as well as desktop.

Before and After: A Worked Example

Take a realistic hand-written component stylesheet with comments, indentation, and blank lines between rule blocks. Minification compresses it substantially, and the savings scale with how much formatting the source carried:

StylesheetBeforeAfterSaved
Component styles, heavily commented11,400 bytes7,900 bytes31 percent
Theme variables and rules, 2-space indent26,800 bytes19,100 bytes29 percent
Print and email styles, tab indent6,300 bytes4,800 bytes24 percent

The pattern in the first row is worth noting: comments are dense bytes. A stylesheet where every section starts with a three-line explanation can lose close to a third of its size from comment removal alone. The last-semicolon optimization is small but free, typically one byte per rule, which on a thousand-rule bundle is about a kilobyte.

An honest framing for these numbers: minification and server compression are different layers. Gzip or Brotli on the server typically removes another 70 to 80 percent from whatever the minifier leaves, and minified input compresses slightly better than formatted input because repetition and padding are gone. Run both; minification is the build step, compression is the server configuration, and neither substitutes for the other.

How to Use the Minifier (Step by Step)

  1. Paste the CSS you want to compact. Minification runs live, and byte savings appear next to the output.
  2. Skim the result briefly. The main thing to look for is a comment you actually need to keep, such as a license header, because comments do not survive.
  3. Copy the minified CSS into your build output or production stylesheet.
  4. Keep the formatted original in your repository as the source of truth and re-minify on each deploy, never editing the minified file by hand.

Why the Last Semicolon Goes

CSS grammar allows the final declaration in a block to omit its trailing semicolon, because the closing brace terminates the declaration regardless. Every semicolon before a closing brace is therefore a removable byte. The minifier drops them all. The same logic applies to whitespace around colons, commas, and combinators: color: #ff0000 and color:#ff0000 are identical to the parser, and the minifier keeps the compact form throughout.

One precision note: the minifier removes whitespace between tokens but does not perform the deeper rewrites that dedicated build-time minifiers can, such as merging shorthand properties, converting colors to shorter notations, or renaming classes. Those transformations interact with the rest of your stylesheet and JavaScript, and they deserve a tested build pipeline. What this tool removes is the safe subset: comments, whitespace, and optional semicolons, all provably invisible to the renderer.

One Rule, Before and After

A single block shows every transformation at once. Imagine a card component written the way humans write CSS: the selector on one line, an opening brace, two spaces of indent per declaration, a comment above the box-shadow line explaining the soft-light trick, a trailing semicolon after the final declaration, and a blank line before the closing brace. That block spans roughly nine lines and about 310 bytes. After minification it is one line of about 215 bytes: the comment is gone, the indentation and blank lines are gone, the spaces around colons are gone, and the trailing semicolon before the brace is gone. The rendered card is identical in both versions; the browser cannot tell them apart, because none of the removed characters participates in the cascade.

Multiplying that single-rule ratio across a real stylesheet is exactly what the byte report does for your input. The savings shown earlier, in the 24 to 31 percent range, are just this local effect accumulated over every rule, comment, and blank line in the file.

What Gets Preserved

Everything that affects rendering survives. Media query structure is intact, so responsive behavior is unchanged. Keyframe animations keep their percentages and properties. Vendor-prefixed properties and at-rules pass through exactly. Custom properties, the var declarations that theming systems depend on, are untouched, including the important distinction between a variable defined on a root element and one overridden deeper in the cascade.

Strings need no special handling because they contain no removable whitespace by definition; a font name with spaces keeps its spaces and its quotes. Comments inside the stylesheet are the one category that is deliberately not preserved, with the exception of nothing: all comments go. If a license header must remain in production CSS, add it back at the top of the minified output as a single comment, or serve license information in a separate file, which is the approach most build tools take.

The Deployment Workflow

The reliable pattern mirrors every other asset on a modern site: a formatted master in source control, a minified artifact at build time. If you inherit a minified stylesheet that needs editing, run it through the paired beautifier first, make the change in readable form, and minify again. Hand-editing minified CSS is a reliable source of subtle bugs, because a single deleted semicolon in a long unbroken line is almost invisible during review.

Minifying before minifying, so to speak, is also a reasonable audit step: run the tool on your current production stylesheet and compare the byte savings. A large saving means the deployed file was shipped without minification and visitors have been downloading formatting bytes; a small saving means your build pipeline is already doing its job.

Tips and Best Practices

  • Minify at build or deploy time from a formatted master, and never edit minified output directly.
  • Move documentation comments into the repository or a separate doc file before stripping them from production CSS.
  • Pair with server compression for the full effect; the numbers in this tool measure the minification layer only.
  • Re-add a license header as a single comment at the top of minified output when attribution requires it.
  • Use the byte report to audit whether your current production CSS was actually minified.
  • Round-trip check after minifying a critical theme: load the page and confirm custom-property overrides still apply in the expected order.

Frequently Asked Questions

How many bytes does CSS minification save?
Typically 24 to 31 percent for hand-written stylesheets. A commented, indented 11,400-byte component file might drop to about 7,900 bytes, and a 26,800-byte theme file to about 19,100 bytes. Comment-dense files save the most, while already-compact output saves little. The tool reports exact before and after byte counts for your input. Server-side gzip or Brotli then typically shrinks the result another 70 to 80 percent on the wire.
Is it safe to remove the last semicolon before a closing brace in CSS?
Yes, completely. CSS grammar treats the closing brace as a declaration terminator, so the semicolon before it is optional and removing it cannot change behavior. The minifier strips these automatically. The same is true of whitespace around colons, commas, and combinators. What is not safe is removing semicolons between declarations, and the tool never does that, since a missing internal semicolon merges two declarations and silently drops the second one.
Does CSS minification remove my comments?
Yes, all of them. Comments are bytes that every visitor downloads and no browser renders, so they are the highest-value removal after whitespace. If you need a license header in production CSS, paste a single comment line back at the top of the minified output, or serve license details in a separate file as most build tools do. Explanatory comments about hacks and browser workarounds belong in your formatted source file, which stays in your repository.
Will minifying CSS break media queries or animations?
No. The minifier removes whitespace, comments, and optional semicolons only. Media query conditions, their wrapped rules, and keyframe percentages are structural and pass through intact, so responsive behavior and animations are unchanged. Custom properties and vendor-prefixed properties are also preserved exactly. The transformations that could affect those, such as merging shorthand properties or renaming classes, are outside this tool's scope and belong in a tested build pipeline.
Should I minify CSS if my server already uses gzip?
Yes, because the two stack rather than compete. Compression removes redundancy in the byte stream and typically cuts CSS by 70 to 80 percent on the wire, while minification removes bytes before compression starts, and cleaner input compresses marginally better. Minification is a build-time step and compression is server configuration; the fastest sites run both. Minifying also guarantees compact output for the rare visitors or proxies where compression is disabled.
How do I edit a CSS file that is already minified?
Do not edit it directly. Run it through the paired CSS beautifier first, which restores one declaration per line and readable indentation, make your changes in the readable version, and minify again before deploying. Editing minified CSS by hand invites subtle bugs because a deleted or doubled semicolon in a single long line is nearly invisible in review. Keep the beautified master in source control and treat minified output as a disposable build artifact.

Related Tools