Remove CSS Comments Online: Strip Comments Without Full Minification
Not every CSS optimisation task requires full minification. Sometimes you want a smaller file that's still readable — indentation intact, properties on separate lines — with only the comments gone. This tool does exactly that: paste your CSS, enable the comment options you want, and get clean output without collapsing your whitespace.
Block comments vs. line comments in CSS
The CSS specification only defines one comment syntax: block comments, delimited by /* and */. They can appear on a single line or span many lines, and can be placed anywhere whitespace is valid — between selectors, between declarations, even inside a property value in some contexts.
Line comments (// text) aren't part of the CSS spec, but they're common in Sass, Less, and PostCSS source files. They also appear in raw CSS that's been compiled from a preprocessor without full stripping. Modern browsers silently ignore them, but they're technically invalid and add unnecessary bytes. This tool removes both kinds.
How much do comments add to a stylesheet?
It depends on the team's documentation habits. A lightly commented stylesheet might carry 3–5% comment content by character count. A thoroughly documented one — with section headers, browser-hack explanations, and component notes — can reach 20–40%. On a 100 KB stylesheet, that's 20–40 KB of bytes that every visitor downloads on every page load and that the browser's CSS parser must process before any rendering begins.
The impact is larger on uncached first loads and for users on constrained mobile connections. Stripping comments is one of the cheapest optimisations available: the file gets smaller, the code behaviour doesn't change at all, and the source in version control stays as documented as you want it.
Comment removal vs. full minification
Full minification collapses all whitespace, removes comments, and produces a single-line file. That's appropriate for production deployments behind a build pipeline. But there are cases where you want the output to remain somewhat readable: you're reviewing a colleague's CSS, you're debugging a live site and need to keep properties on separate lines for DevTools readability, or you want a partially compressed file you can still diff in version control.
Removing comments without touching whitespace gives you a middle ground. You get the file size savings from the comments — often the largest single contributor to stylesheet bloat in documented codebases — without sacrificing readability. For the full treatment, run the result through a CSS minifier afterwards.
The other options in this tool
Empty line removal. Strips blank lines between rules and declarations. Doesn't affect functionality but reduces line count, which matters when file-size metrics count newlines as bytes (they do — a newline is 0x0A, one byte in UTF-8).
!important removal. Strips every !important declaration. Useful when inheriting a codebase that overused it and you're refactoring specificity. Use with caution — removing !important can change visual output if the cascade was relying on it.
Alphabetical property sorting. Reorders declarations within each rule alphabetically. This is a stylistic choice that some teams enforce via Stylelint's declaration-property-sort-order rule. Sorted properties make diffs smaller and rules easier to scan. The CSS formatter also offers this option alongside full pretty-printing.
When to use this tool in a workflow
The ideal workflow keeps commented source CSS in your repository and strips comments at deploy time via a build tool (webpack's css-loader, Vite's built-in PostCSS pipeline, or a Gulp task with gulp-strip-css-comments). If your project doesn't have that pipeline, this tool fills the gap.
It's also useful for one-off cleanup: you've received a CSS file from a vendor or a design handoff, it's full of notes that made sense during development, and you want a cleaner version to integrate into your project. Paste, strip, copy — the whole operation takes seconds.
For projects where you're also cleaning JavaScript, the same principle applies: comments in .js files add weight. The JS minifier handles both // and /* */ removal for JavaScript files in one step.
Licensed code and preserving copyright comments
Some CSS files include a license header at the top — typically a block comment containing the library name, author, version, and MIT or Apache license text. Stripping these comments is technically permissible under most open-source licenses only if the license is documented somewhere else (your LICENSE file, your package metadata, etc.). If you're distributing the minified CSS publicly and you've removed a license comment, confirm the original license terms allow that before publishing.
A common convention is to use /*! (exclamation mark after the opening) to mark comments as protected — build tools like UglifyCSS and clean-css respect this convention and preserve those comments even in aggressive minification mode. This tool strips all comments regardless; if you need license-comment preservation, check the advanced settings of your build tool instead.
Combining with full minification
Removing comments is the first step of full minification, not a replacement for it. A stylesheet with comments stripped but whitespace preserved is smaller than the original, but a fully minified stylesheet (no comments, no whitespace, no trailing semicolons) is smaller still. If file size is the priority, run the CSS minifier instead — it strips comments and compacts everything else in a single pass. Use this comment-only tool when you want a smaller file that's still readable in an editor or in browser DevTools.