CLEANCSS(1)
π NAME π
okay so bestie, meet cleancss β a fast and efficient CSS optimizer. she takes your chunky stylesheet and makes it β¨snatchedβ¨. no cap.
π¦ SYNOPSIS π¦
cleancss [options] <source-file ...>
π OPTIONS π
-v,--versionβ outputs the version number. that's the whole job, and she does it flawlessly π-c,--compatibility [ie7|ie8]β forces compatibility mode. (there are advanced examples in the Readme if you wanna go deeper, iykyk)-d,--debugβ shows debug information: the minification time and the compression efficiency. receipts, basically π§Ύ-f,--format <options>β controls the output formatting. examples are down below β¬οΈ-o,--output [output-file]β uses [output-file] as the output instead of STDOUT. she can pick a destination, she's not like other girls.-O <n> [optimizations]β turns on level n optimizations. optionally she'll accept a list of fine-grained options too. defaults to1. examples below π₯--inline [rules]β enables inlining for the listed sources. defaults tolocal.--inline-timeout [seconds]β per-connection timeout when she's out here fetching remote stylesheets. defaults to 5 seconds.--remove-inlined-filesβ removes files that were inlined in<source-file ...>or via@importstatements.--skip-rebaseβ disables URLs rebasing.--source-mapβ enables building the input's source map.--source-map-inline-sourcesβ enables inlining sources inside source maps.--input-source-map [file]β specifies the path of the input source map file.-h,--helpβ outputs usage information. the iconique classic.
π Examples: π
%> cleancss one.css
%> cleancss -o one-min.css one.css
%> cleancss -o merged-and-minified.css one.css two.css three.css
%> cleancss one.css two.css three.css | gzip -9 -c > merged-minified-and-gzipped.css.gz
π Formatting options: π
%> cleancss --format beautify one.css
%> cleancss --format keep-breaks one.css
%> cleancss --format 'indentBy:1;indentWith:tab' one.css
%> cleancss --format 'breaks:afterBlockBegins=on;spaces:aroundSelectorRelation=on' one.css
so here's the whole menu of formatting knobs, bestie:
breaksβ controls where to insert breaks.afterAtRuleβ controls if a line break comes after an at-rule, e.g.@charset. defaults tooff(alias tofalse).afterBlockBeginsβ controls if a line break comes after a block begins, e.g.@media. defaults tooff.afterBlockEndsβ controls if a line break comes after a block ends. defaults tooff.afterCommentβ controls if a line break comes after a comment. defaults tooff.afterPropertyβ controls if a line break comes after a property. defaults tooff.afterRuleBeginsβ controls if a line break comes after a rule begins. defaults tooff.afterRuleEndsβ controls if a line break comes after a rule ends. defaults tooff.beforeBlockEndsβ controls if a line break comes before a block ends. defaults tooff.betweenSelectorsβ controls if a line break comes between selectors. defaults tooff.
indentByβ controls the number of characters to indent with. defaults to0.indentWithβ controls the character to indent with. can bespaceortab. defaults tospace.spacesβ controls where to insert spaces.aroundSelectorRelationβ controls if spaces come around selector relations, e.g.div > a. defaults tooff.beforeBlockBeginsβ controls if a space comes before a block begins, e.g..block {. defaults tooff.beforeValueβ controls if a space comes before a value, e.g.width: 1rem. defaults tooff.
wrapAtβ controls the maximum line length. defaults tooff.
β Level 0 optimizations: β
%> cleancss -O0 one.css
π Level 1 optimizations: π
%> cleancss -O1 one.css
%> cleancss -O1 removeQuotes:off;roundingPrecision:4;specialComments:1 one.css
%> cleancss -O1 all:off;specialComments:1 one.css
and the fine-grained level 1 girlies:
cleanupCharsetsβ controls@charsetmoving to the front of a stylesheet. defaults toon.normalizeUrlsβ controls URL normalization. defaults toon.optimizeBackgroundβ controlsbackgroundproperty optimizations. defaults toon.optimizeBorderRadiusβ controlsborder-radiusproperty optimizations. defaults toon.optimizeFilterβ controlsfilterproperty optimizations. defaults toon.optimizeFontWeightβ controlsfont-weightproperty optimizations. defaults toon.optimizeOutlineβ controlsoutlineproperty optimizations. defaults toon.removeEmptyβ controls removing empty rules and nested blocks. defaults toon(since 4.1.0).removeNegativePaddingsβ controls removing negative paddings. defaults toon.removeQuotesβ controls removing quotes when they're unnecessary. defaults toon.removeWhitespaceβ controls removing unused whitespace. defaults toon.replaceMultipleZerosβ controls removing redundant zeros. defaults toon.replaceTimeUnitsβ controls replacing time units with shorter values. defaults toon.replaceZeroUnitsβ controls replacing zero values with units. defaults toon.roundingPrecisionβ rounds pixel values toNdecimal places;offdisables rounding. defaults tooff.selectorsSortingMethodβ denotes the selector sorting method; can benaturalorstandard. defaults tostandard.specialCommentsβ denotes a number of/*! ... */comments preserved. defaults toall.tidyAtRulesβ controls at-rules (e.g.@charset,@import) optimizing. defaults toon.tidyBlockScopesβ controls block scopes (e.g.@media) optimizing. defaults toon.tidySelectorsβ controls selectors optimizing. defaults toon.
π₯ Level 2 optimizations: π₯
%> cleancss -O2 one.css
%> cleancss -O2 mergeMedia:off;restructureRules:off;mergeSemantically:on;mergeIntoShorthands:off one.css
%> cleancss -O2 all:off;removeDuplicateRules:on one.css
and the level 2 menu, all of it, no skips:
mergeAdjacentRulesβ controls adjacent rules merging. defaults toon.mergeIntoShorthandsβ controls merging properties into shorthands. defaults toon.mergeMediaβ controls@mediamerging. defaults toon.mergeNonAdjacentRulesβ controls non-adjacent rule merging. defaults toon.mergeSemanticallyβ controls semantic merging. defaults tooff.overridePropertiesβ controls property overriding based on understandability. defaults toon.reduceNonAdjacentRulesβ controls non-adjacent rule reducing. defaults toon.removeDuplicateFontRulesβ controls duplicate@font-faceremoving. defaults toon.removeDuplicateMediaBlocksβ controls duplicate@mediaremoving. defaults toon.removeDuplicateRulesβ controls duplicate rules removing. defaults toon.removeEmptyβ controls removing empty rules and nested blocks. defaults toon(since 4.1.0).removeUnusedAtRulesβ controls unused at rule removing. defaults tooff(since 4.1.0).restructureRulesβ controls rule restructuring. defaults tooff.skipPropertiesβ controls which properties won't be optimized. defaults to an empty list, which means all of them will be optimized (since 4.1.0).
π this page is from cleancss 4.3.0, dated February 2020, and it lives in section 1 of the manual (User Commands). go forth and minify, bestie π«Άβ¨
π¦ where this page comes from
- debian bookworm: cleancss 5.3.1+~5.6.1-1 Β· MIT
- debian trixie: cleancss 5.3.3+~5.6.3-1 Β· MIT
- ubuntu jammy: cleancss 5.2.4+~5.5.2-1ubuntu1 Β· MIT
- ubuntu noble: cleancss 5.3.2+~5.6.2-1ubuntu1 Β· MIT
- ubuntu questing: cleancss 5.3.3+~5.6.3-1ubuntu1
- ubuntu resolute: cleancss 5.3.3+~5.6.3-4ubuntu1 Β· MIT
- ubuntu stonking: cleancss 5.3.3+~5.6.3-4ubuntu1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms