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
Metadata
Release files for cssfix 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cssfix-2.1.0.tar.gz | 3.6 kB | Without provenance | Details for cssfix-2.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cssfix-2.1.0-py3-none-any.whl | Python 3 | none | any | Details for cssfix-2.1.0-py3-none-any.whl |
Total release size: 7.4 kB
Release files / cssfix-2.1.0.tar.gz
| Download URL | cssfix-2.1.0.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1c9a6579c84051a78772b0e946485152e064b063c23e8f97a97c6b37c47ebabf
|
|
BLAKE2b-256 checksum How to use checksums |
1d36f62e46584aa4357cab3bc21ae5b7682218a33bd74765273479cab7ee14f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.0
|
Release files / cssfix-2.1.0-py3-none-any.whl
| Download URL | cssfix-2.1.0-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3f1b50d645c95c95b556723be87b7aa7268b4575ec0e0ac8a757e141c6ffb47c
|
|
BLAKE2b-256 checksum How to use checksums |
dba0d081b2a1283e93559d0d59fbe82cd73b120f04e4c5703ba610a894967e52
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.0
|
Security for cssfix 2.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.