
Research
/Security News
Fake imToken Chrome Extension Steals Seed Phrases via Phishing Redirects
Mixed-script homoglyphs and a lookalike domain mimic imToken’s import flow to capture mnemonics and private keys.
strip-css-comments
Advanced tools
Strip comments from CSS
Also available as a gulp/grunt/broccoli plugin.
$ npm install --save strip-css-comments
var stripCssComments = require('strip-css-comments');
// by default important comments `/*!` are preserved
stripCssComments('/*! <copyright> */ body { /* unicorns */color: hotpink; }');
//=> '/*! <copyright> */ body { color: hotpink; }'
// `preserve: false` will strip all comments including `/*!`
stripCssComments(
'/*! <copyright> */ body { /* unicorns */color: hotpink; }',
{preserve: false}
);
//=> 'body { color: hotpink; }'
// preserve comments based on a regex
stripCssComments(
'/*# preserved */ body { /* unicorns */color: hotpink; }',
{preserve: /^#/}
);
//=> '/*# preserved */ body { color: hotpink; }'
// preserve comments based on the return value of the supplied function
stripCssComments(
'/*# preserved */ body { /* unicorns */color: hotpink; }',
{
preserve: function (comment) {
return comment.charAt(0) === '#';
}
}
);
//=> '/*# preserved */ body { color: hotpink; }'
Required
Type: string
String with CSS.
Type: boolean, RegExp, function
Default: true
true - Preserve comments that use the /*! */ syntaxfalse - Strip all commentsRegExp - Preserve comments where the comment body matches a regular expression.Function - Preserve comments for which a function returns true. The function is called on each comment, gets the comment body as the first argument, and is expected to return a boolean of whether to preserve the comment.$ npm install --global strip-css-comments
$ strip-css-comments --help
Usage
$ strip-css-comments <input-file> > <output-file>
$ strip-css-comments < <input-string>
Option
-a, --all Strip all comments including `/*!`
Example
$ strip-css-comments src/app.css > dist/app.css
$ strip-css-comments < src/app.css --all
$ npm run bench
MIT © Sindre Sorhus
FAQs
Strip comments from CSS
The npm package strip-css-comments receives a total of 61,083 weekly downloads. As such, strip-css-comments popularity was classified as popular.
We found that strip-css-comments demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Mixed-script homoglyphs and a lookalike domain mimic imToken’s import flow to capture mnemonics and private keys.

Security News
Latio’s 2026 report recognizes Socket as a Supply Chain Innovator and highlights our work in 0-day malware detection, SCA, and auto-patching.

Company News
Join Socket for live demos, rooftop happy hours, and one-on-one meetings during BSidesSF and RSA 2026 in San Francisco.