premailer
Turns CSS blocks into style attributes
Decision gist · record as of 2026-08-14
Yes, if you are building email systems. Premailer solves a real, specific problem—email clients require inline styles—and does it reliably. The dormant maintenance is a minor concern given the stable classifier and zero known vulnerabilities, but verify that its CSS and HTML parsing behavior still meets your email client compatibility needs before adopting it for new projects.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- By default, premailer attempts to download external stylesheets over the network; use allow_network=False to prevent this if needed.
- Low friction: pure Python wheel with five straightforward runtime dependencies (lxml, cssselect, cssutils, requests, cachetools).
- Maintenance is dormant—last release was 2021-08-02 and last commit 2023-12-16—but the package is marked Production/Stable and has no known vulnerabilities.
License · maintenance · safety
Python (permissive) — Licensed under the Python Software Foundation License, a permissive license. No restrictions on use, modification, or distribution in commercial or private projects.
last release 2021-08-02 (1838 days) · last repo commit 2023-12-16 · 1,084 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 5,013,987 downloads/mo, #2,181 on PyPI
Alternatives
Verify before relying
pip install premailer
from premailer import transform
html = '<style>p { color: red; }</style><p>Hello</p>'
result = transform(html)
print(result)- Whether the dormant maintenance status (last release 2021-08-02) affects compatibility with modern email clients or CSS specifications.
- Performance characteristics when processing large HTML documents or many external stylesheets.
What it is and what it does
Premailer is a Python library that transforms HTML documents by inlining CSS styles into HTML element attributes. It parses HTML, extracts CSS from style blocks and external stylesheets, and rewrites the DOM to apply those styles as inline style attributes—a requirement for most email clients, which strip out style tags for security reasons.
The package handles relative URL rewriting (converting relative links to absolute ones using a base URL), CSS selector parsing via cssutils and cssselect, and HTML parsing via lxml. It offers both a simple transform() function for basic use and a full Premailer class for advanced configuration. It can preserve or strip certain CSS features (pseudoclasses, !important declarations, class attributes) and supports command-line usage for batch processing.
Use it for
- Prepare HTML newsletters and transactional emails for delivery by inlining all styles before sending.
- Convert relative URLs in email templates to absolute URLs using a base_url parameter.
- Strip !important declarations and pseudoclasses from CSS to ensure compatibility with email clients.
- Process HTML templates from a file or stdin via the command-line interface for CI/CD pipelines.
- Preserve specific CSS or links (e.g., handlebar syntax, cid: attachments) while inlining other styles.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you are building email systems.
Premailer solves a real, specific problem—email clients require inline styles—and does it reliably. The dormant maintenance is a minor concern given the stable classifier and zero known vulnerabilities, but verify that its CSS and HTML parsing behavior still meets your email client compatibility needs before adopting it for new projects.
Install
premailer on PyPI
Before you install
Low friction: pure Python wheel with five straightforward runtime dependencies (lxml, cssselect, cssutils, requests, cachetools). Maintenance is dormant—last release was 2021-08-02 and last commit 2023-12-16—but the package is marked Production/Stable and has no known vulnerabilities.
By default, premailer attempts to download external stylesheets over the network; use allow_network=False to prevent this if needed.
License in practice
Licensed under the Python Software Foundation License, a permissive license. No restrictions on use, modification, or distribution in commercial or private projects.
Quickstart
pip install premailer
from premailer import transform
html = '<style>p { color: red; }</style><p>Hello</p>'
result = transform(html)
print(result)
Verify before relying
- Whether the dormant maintenance status (last release 2021-08-02) affects compatibility with modern email clients or CSS specifications.
- Performance characteristics when processing large HTML documents or many external stylesheets.
Package facts
| License | Python permissive |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 5 packageslxmlcssselectcssutilsrequestscachetools |
| Maintenance | Dormant 1,838 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 5,013,987 / month, #2,181 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/StableEnvironment :: Other EnvironmentEnvironment :: Web EnvironmentIntended Audience :: DevelopersLicense :: OSI Approved :: Python Software Foundation LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: CommunicationsTopic :: Internet :: WWW/HTTPTopic :: Other/Nonlisted TopicTopic :: Software Development :: Libraries :: Python Modules |
Evidence: premailer-3.10.0-py2.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 › “html email preprocessing”
- premailerConverts CSS style blocks into inline style attributes on HTML…
- unstructuredIngests and pre-processes unstructured documents (PDFs, HTML, Word,…
- pretty-html-tableConverts pandas DataFrames into styled HTML tables ready for email,…
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 django-premailer · css-inline · pynliner · email-to · cssutils · emails · prettierfier · pretty-html-table · webcolors · djangocms-admin-style