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.1.0.tar.gz (3.6 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.1.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for cssfix-2.1.0.tar.gz
Algorithm Hash digest
SHA256 1c9a6579c84051a78772b0e946485152e064b063c23e8f97a97c6b37c47ebabf
MD5 0906316965cff926ea1feceeca7e6589
BLAKE2b-256 1d36f62e46584aa4357cab3bc21ae5b7682218a33bd74765273479cab7ee14f7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cssfix-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.8 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3f1b50d645c95c95b556723be87b7aa7268b4575ec0e0ac8a757e141c6ffb47c
MD5 4df830ee867a4481276f94433619dc9d
BLAKE2b-256 dba0d081b2a1283e93559d0d59fbe82cd73b120f04e4c5703ba610a894967e52

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