dict2css
A μ-library for constructing cascading style sheets from Python dictionaries.
Decision gist · record as of 2026-08-14
Yes, if you need to work with CSS as Python data structures. The library is small, actively maintained, has no known vulnerabilities, and installs with low friction. MIT licensing is unrestrictive. The main unknown is whether it handles advanced CSS features (at-rules, media queries) or only basic selectors and properties—verify against your use case before committing.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low friction installation with a pure-Python wheel.
- Active maintenance as of 2026-07-06, with support across Python 3.8–3.13 and PyPy.
License · maintenance · safety
MIT (permissive) — MIT license is permissive; you can use, modify, and distribute dict2css with minimal restrictions.
last release 2026-05-21 (85 days) · last repo commit 2026-07-06 · 2 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 669,534 downloads/mo, #5,413 on PyPI
Alternatives
Verify before relying
from dict2css import dump
styles = {
"body": {"margin": "0", "padding": "0"},
".header": {"background-color": ("red", "important")}
}
css_string = dump(styles)- Whether the package handles CSS at-rules (@media, @keyframes, etc.) or only simple selectors and properties.
- Performance characteristics when working with large stylesheets.
- Whether round-trip fidelity (dump then load) preserves all CSS semantics.
What it is and what it does
dict2css is a lightweight library that bridges Python dictionaries and CSS stylesheets. It provides dump and load functions—similar to the json and toml standard library modules—allowing you to construct CSS from nested Python dicts where keys are CSS selectors and values are property mappings. Property values can optionally include an "important" flag as a tuple. The library depends on domdf-python-tools and tinycss2 for parsing and serialization.
The package targets developers who want to programmatically generate or manipulate CSS within Python, such as in static site generators, template systems, or configuration-driven styling. It is typed, actively maintained, and supports modern Python versions from 3.8 onward.
Use it for
- Generate CSS stylesheets programmatically from configuration dictionaries in static site generators or template engines.
- Parse existing CSS files into Python dicts for inspection, modification, or transformation.
- Build theme or style configuration systems where CSS is defined as nested Python data structures.
- Serialize dynamic styling rules computed at runtime into valid CSS output.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need to work with CSS as Python data structures.
The library is small, actively maintained, has no known vulnerabilities, and installs with low friction. MIT licensing is unrestrictive. The main unknown is whether it handles advanced CSS features (at-rules, media queries) or only basic selectors and properties—verify against your use case before committing.
Install
dict2css on PyPI
Before you install
Low friction installation with a pure-Python wheel. Active maintenance as of 2026-07-06, with support across Python 3.8–3.13 and PyPy.
License in practice
MIT license is permissive; you can use, modify, and distribute dict2css with minimal restrictions.
Quickstart
from dict2css import dump
styles = {
"body": {"margin": "0", "padding": "0"},
".header": {"background-color": ("red", "important")}
}
css_string = dump(styles)
Verify before relying
- Whether the package handles CSS at-rules (@media, @keyframes, etc.) or only simple selectors and properties.
- Performance characteristics when working with large stylesheets.
- Whether round-trip fidelity (dump then load) preserves all CSS semantics.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.8 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packagesdomdf-python-toolstinycss2 |
| Maintenance | Actively maintained 85 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 669,534 / month, #5,413 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Libraries :: Python ModulesTyping :: Typed |
Evidence: dict2css-0.6.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 › “python dict to css”
- dict2cssdict2css converts Python dictionaries to CSS stylesheets and parses…
- tinycss2tinycss2 parses CSS strings into token and block objects, and…
- cssminCompresses CSS files by removing unnecessary characters while…
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 cssutils · pynliner · cssselect2 · css-inline · cssselect · dom-toml · tree-sitter-css · csscompressor · tinycss2 · jsons