Skip to content

Seekiii/cssfix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

cssfix

cssfix is a lightweight Python utility that cleans and optimizes your CSS code.
It removes comments πŸ—‘οΈ, merges duplicate selectors 🧩, and outputs a compact result ⚑.
Perfect for small projects, automation, or integrating into build tools.


✨ Features

  • 🧽 Removes all CSS comments
  • πŸ” Merges repeated selectors (e.g. .class1 {} multiple times)
  • 🧠 Consolidates CSS properties without duplicates
  • πŸ“₯ Takes raw CSS string as input
  • πŸ“€ Returns optimized CSS string output immediately on instantiation
  • 🐍 Pure Python - no dependencies

πŸ“¦ Installation

From PyPI:

pip install cssfix

πŸš€ Usage

from cssfix import css

css_text = """
/* This is a comment */
.box {
	color: red;
}
.box {
	background: blue;
}
"""

optimized_css = css(css_text)
print(optimized_css)

βœ… Output:

.box{color:red;background:blue;}

πŸ“š API

class css(css_text: str)

Creates a new instance of the CSS optimizer and immediately returns optimized CSS string.

Parameters:

css_text: str β€” Raw CSS code to optimize

Returns:

str β€” Optimized, minified CSS with merged selectors and no comments

About

Simple CSS optimizer module for merging class properties

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages