csscompress
A fast and safe CSS minifier for Python — the community-maintained fork of
csscompressor (itself a Python
port of YUI Compressor's CSS minifier).
What's fixed vs upstream
Upstream csscompressor is dormant (last release 0.9.5, November 2017). csscompress
continues it with:
- Data-URI whitespace fix:
url("data:...")values containing SVG or MathML were minified aggressively (remove_ws=True), destroying the whitespace that SVG/MathML data URIs need to render.csscompresspreserves whitespace insideurl(...)patterns, sodata:image/svg+xml,...CSS works after minification. - Proper
__version__attribute (upstream shipped a stale one).
Usage
from csscompress import compress
minified = compress("body { color: #ff0000; /* comment */ }")
There is also a CLI:
$ python -m csscompress input.css > output.min.css
API
compress(css: str) -> str— minify a CSS stylesheet.compress_partitioned(css: str) -> list[str]— minify and return each top-level rule separately.
License
BSD (revised) — see LICENSE. The original project is a Python port of the
YUI Compressor CSS minifier:
- Portions Copyright (c) 2013 Sprymix Inc.
- Author of the Python port: Yury Selivanov
- Original authors: Julien Lecomte, Isaac Schlueter, Stoyan Stefanov, and contributors; Portions Copyright (c) 2011-2013 Yahoo! Inc.
Metadata
Release files for csscompress 0.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 | |
|---|---|---|---|
| csscompress-0.1.0.tar.gz | 9.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| csscompress-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.4 kB
Release files / csscompress-0.1.0.tar.gz
| Download URL | csscompress-0.1.0.tar.gz |
|---|---|
| Size | 9.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9e87e0d26bd904b8c544d1ca3327a9fa99ae61ce72d04153e0e7fe9fe1179cca
|
|
BLAKE2b-256 checksum How to use checksums |
8d31eb99ae11fec861cc99bbaaacde146c3cc88db963d7f29f6ea0f493caee16
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 13, 2026.
Transparency logRelease files / csscompress-0.1.0-py3-none-any.whl
| Download URL | csscompress-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8977d6fac07954778d6ffaa83ee23edd66391dcd61f01d97448e708b863a2be7
|
|
BLAKE2b-256 checksum How to use checksums |
b54a3a50aa62cffdcc7c90a36e3eb1095b462966de85a0d43108cdeae2075350
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 13, 2026.
Transparency log