Skip to main content

Simple CSS optimizer module for merging class properties

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cssfix-2.0.1.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cssfix-2.0.1-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file cssfix-2.0.1.tar.gz.

File metadata

  • Download URL: cssfix-2.0.1.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.0

File hashes

Hashes for cssfix-2.0.1.tar.gz
Algorithm Hash digest
SHA256 1dcf1c1ff2da4641405b503dc480a89ae65b3659cb43960738dd20d763ecd85b
MD5 66adef5c2b0dc78f8d79509124e91351
BLAKE2b-256 88852d6be3e689e0c3e8bec0af81e48e159df1e4a1a65e120fc3ca17c4da7301

See more details on using hashes here.

File details

Details for the file cssfix-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: cssfix-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.0

File hashes

Hashes for cssfix-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 efce0a3e7ffbc452a467c752f09289488812fb952f7d498eaa1afc9481af87e8
MD5 c65eb0ec30e8a04b48e9f545c3168afe
BLAKE2b-256 576959eb9c25aa7c454f0703af40cf746c5ea8632fb5e8536b5a2302bee26e7c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page