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.0.tar.gz (3.2 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.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cssfix-2.0.0.tar.gz
  • Upload date:
  • Size: 3.2 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.0.tar.gz
Algorithm Hash digest
SHA256 ace9bef2107732b7a5ca1c21a01b0ee9807fab4868132f18cb2bad4a7bef0e2e
MD5 649b7e6b224c42a9c3d2c9297a1634b5
BLAKE2b-256 0f7f904a4f76bbec980a3808700f72e3c59a7fe11b94ee8e157d59d8ab01c6cd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cssfix-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.5 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cfe57a0cd376c3e16b9e48e92f36b5a760e160e205e05b3e5dc010e8f1b49259
MD5 5932bc4d8790c5a4ee599e28570fc5b4
BLAKE2b-256 691aafd9b9c55c08d30a69bba52607eb12c959439af522f8e332f4a666a92cb9

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