cssutils
A CSS Cascading Style Sheets library for Python
Decision gist · record as of 2026-08-14
Yes, if you need to parse, validate, or programmatically modify CSS as structured data. Install friction is low, maintenance is active, and there are no known security vulnerabilities. The copyleft license (LGPL-3.0-or-later) requires attention if you plan proprietary distribution. Not suitable for rendering or for thread-concurrent use.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python >=3.10.
- cssutils is known to be thread unsafe.
- Low friction install with only two runtime dependencies (more_itertools, encutils).
License · maintenance · safety
LGPL-3.0-or-later (copyleft) — Licensed under LGPL-3.0-or-later (copyleft). Derivative works and modifications must be distributed under compatible terms; proprietary use requires careful license review.
last release 2026-04-27 (109 days) · last repo commit 2026-04-29 · 92 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 9,443,090 downloads/mo, #1,533 on PyPI
Alternatives
Verify before relying
import cssutils
css = 'a { color: red; }'
sheet = cssutils.parseString(css)
for rule in sheet:
if rule.type == rule.STYLE_RULE:
rule.style['color'] = 'blue'
print(sheet.cssText)- Whether the package handles modern CSS features beyond CSS 2.1 and CSS 3 (e.g., CSS Grid, Flexbox, custom properties edge cases).
- Performance characteristics when parsing large stylesheets or many rules in sequence.
- Specific validation strictness for CSS properties and whether it can be configured.
What it is and what it does
cssutils is a CSS parser and DOM builder for Python that reads CSS stylesheets into a structured object model you can inspect and modify programmatically. It implements the W3C DOM Level 2 Style specification and supports CSS 2.1 and parts of CSS 3, including namespaces, media queries, page rules, and custom properties. The package does not render CSS—it is purely for parsing, validation, and serialization.
You use it to load a CSS string or file, walk through rules and properties, modify values or priorities, add or remove rules, and serialize the result back to text. It depends on more_itertools and encutils for utility functions. The library is mature (first released in 2007) and actively maintained, though it is not thread-safe and requires Python 3.10 or later.
Use it for
- Programmatically modify CSS stylesheets in build pipelines or code generation tools.
- Validate CSS syntax and property values before deployment or in linting workflows.
- Extract and analyze CSS rules, selectors, and properties from stylesheets for auditing or transformation.
- Build CSS dynamically by constructing rules and properties in code and serializing them to text.
- Parse CSS from HTML documents or external sources and manipulate them as structured data.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need to parse, validate, or programmatically modify CSS as structured data.
Install friction is low, maintenance is active, and there are no known security vulnerabilities. The copyleft license (LGPL-3.0-or-later) requires attention if you plan proprietary distribution. Not suitable for rendering or for thread-concurrent use.
Install
cssutils on PyPI
Before you install
Low friction install with only two runtime dependencies (more_itertools, encutils). Active maintenance with a recent release; last commit 2026-04-29. Marked as Production/Stable.
Requires Python >=3.10. cssutils is known to be thread unsafe.
License in practice
Licensed under LGPL-3.0-or-later (copyleft). Derivative works and modifications must be distributed under compatible terms; proprietary use requires careful license review.
Quickstart
import cssutils
css = 'a { color: red; }'
sheet = cssutils.parseString(css)
for rule in sheet:
if rule.type == rule.STYLE_RULE:
rule.style['color'] = 'blue'
print(sheet.cssText)
Verify before relying
- Whether the package handles modern CSS features beyond CSS 2.1 and CSS 3 (e.g., CSS Grid, Flexbox, custom properties edge cases).
- Performance characteristics when parsing large stylesheets or many rules in sequence.
- Specific validation strictness for CSS properties and whether it can be configured.
Package facts
| License | LGPL-3.0-or-later copyleft |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packagesmore_itertoolsencutils |
| Maintenance | Actively maintained 109 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 9,443,090 / month, #1,533 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyTopic :: InternetTopic :: Software Development :: Libraries :: Python ModulesTopic :: Text Processing :: Markup :: HTML |
Evidence: cssutils-2.15.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “parse CSS stylesheets”
- cssutilscssutils parses and builds CSS stylesheets as a DOM structure without…
- dict2cssdict2css converts Python dictionaries to CSS stylesheets and parses…
- tree-sitter-cssProvides a CSS grammar parser for tree-sitter, enabling incremental…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also dict2css · pynliner · cssselect · css-inline · pyScss · premailer · tinycss2 · cssselect2 · dominate · cssbeautifier