Registry / serialization / mjml
library0.12.0pypypi✓ verified 85d ago

mjml-python is a Python implementation and wrapper around the high-performance Rust MJML engine MRML. It allows compiling MJML markup into responsive HTML without requiring a Node.js runtime, external API calls, or subprocesses. The current version is 0.12.0. Releases are published as needed, often reflecting updates to the underlying MJML standard or significant bug fixes.

pip install mjml
INSTALL
IMPORT
SIG · MJML
M
mjml
serializationpythonv0.12.0
Install
2.1s avg
Import
554ms
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.12.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.572s · 21.2MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 2.1s · import 0.536s · 22MB
20MB installed
● package 20MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

mjml2html
from mjml import mjml2html

This quickstart demonstrates the core functionality: importing `mjml2html` and passing an MJML string to it. The function returns a `Result` object containing the compiled HTML and any potential errors.

from mjml import mjml2html mjml_template = ''' <mjml> <mj-body> <mj-section> <mj-column> <mj-text font-size="20px" color="#F45E43" font-family="Open Sans">Hello, MJML!</mj-text> <mj-button href="https://mjml.io/" background-color="#F45E43">Learn More</mj-button> </mj-column> </mj-section> </mj-body> </mjml> ''' result = mjml2html(mjml_template) if result.errors: print("MJML compilation errors:", result.errors) else: print(result.html)
Debug
Known issues
breakingVersion 0.12.0 officially dropped support for Python 3.6, 3.7, and 3.8. Users on these Python versions must either upgrade their Python environment or pin to an older `mjml` release.
fix
Upgrade to Python 3.9 or newer (e.g., `python -m pip install --upgrade python` if using pyenv, or use a newer system Python). Alternatively, pin `mjml<0.12.0` for older Python versions.
affects: 0.12.0+
breakingThe `css-inline` dependency underwent incompatible API changes across `mjml` versions. Notably, `0.9.1` pinned `css_inline < 0.10`, while `0.10.0` required `css-inline >= 0.11` (which broke Python 3.6), and `0.11.1` accepted `css_inline >= 0.14`. Mixing `mjml` versions or `css-inline` manually can lead to runtime errors.
fix
Always install `mjml` directly via `pip install mjml` without pinning `css-inline` to ensure compatible versions are pulled. If issues arise, check your `pip freeze` output for `css-inline` version conflicts.
affects: 0.9.1, 0.10.0, 0.11.x
breakingA security vulnerability (CVE-2024-26151) was fixed in `v0.11.0` where potentially untrusted input could be rendered directly as HTML, leading to script injection. Users of `0.10.0` are strongly encouraged to upgrade.
fix
Upgrade to `mjml==0.11.0` or newer immediately via `pip install --upgrade mjml`.
affects: 0.10.0
gotchaAs of v0.12.0, comments within your MJML code (`<!-- comment -->`) will now be preserved and present in the generated HTML output by default. In previous versions, these comments might have been stripped.
fix
If you need to remove comments, use the `disable_comments=True` option when calling `mjml2html(mjml_string, disable_comments=True)`.
affects: 0.12.0+
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'mjml'
The `mjml` package has not been installed in the current Python environment.
fix
Install the package using pip: `pip install mjml`.
TypeError: 'module' object is not callable
Attempting to call the `mjml` module directly instead of its `mjml2html` function.
fix
Ensure you are calling the `mjml2html` function: `from mjml import mjml2html; html = mjml2html(...)`.
RuntimeError: Unable to load shared library 'libmjml_python_core.so' or 'mjml_python_core.dll'
This error typically occurs when the underlying Rust binary (MRML) cannot be loaded, usually due to an incompatible system architecture, missing C++ runtime libraries (on Windows), or issues during installation.
fix
Ensure you are on a supported operating system and architecture. For Windows, ensure the Visual C++ Redistributable is installed. Try reinstalling with verbose output to check for build errors: `pip install mjml --verbose`.
Upgrade
Version history
0.12.0latest on PyPI · released Dec 27, 2025
Audit
Dependencies
css-inlinerequiredUsed for inlining CSS directly into the HTML output, which is crucial for email client compatibility.
Agent activity
21 hits · last 30 days
node
20
OpenAI (training)
1
Resources
mjml — pip install mjml · libregistry