{"id":4986,"library":"mjml-python","title":"MJML Python Wrapper","description":"mjml-python is a Python wrapper for MRML, a high-performance Rust port of MJML. It enables rendering MJML templates into email-compatible HTML entirely within Python, eliminating the need for external Node.js services or subprocesses. Currently at version 1.4.0, the library is actively maintained with regular updates, often coinciding with upstream MRML changes.","status":"active","version":"1.4.0","language":"en","source_language":"en","source_url":"https://github.com/mgd020/mjml-python","tags":["email","mjml","html","templating","rust","mrml"],"install":[{"cmd":"pip install mjml-python","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"The primary function for converting MJML to HTML.","symbol":"mjml2html","correct":"from mjml import mjml2html"}],"quickstart":{"code":"from mjml import mjml2html\n\nmjml_template = '''\n<mjml>\n  <mj-body>\n    <mj-section>\n      <mj-column>\n        <mj-text font-size=\"20px\" color=\"#F45E43\">Hello World</mj-text>\n      </mj-column>\n    </mj-section>\n  </mj-body>\n</mjml>\n'''\n\nresult = mjml2html(mjml_template,\n                   disable_comments=True,\n                   fonts={\n                       \"Open Sans\": \"https://fonts.googleapis.com/css?family=Open+Sans:300,400,500,700\"\n                   }\n)\n\nif result.errors:\n    print(\"MJML rendering errors:\", result.errors)\nelse:\n    print(result.html)","lang":"python","description":"Render a basic MJML string to HTML. The `mjml2html` function takes the MJML string and optional keyword arguments for customization, such as disabling comments or specifying custom fonts. It returns a result object containing the rendered HTML and any errors encountered."},"warnings":[{"fix":"Always use `pip install mjml-python` to ensure you get this specific wrapper.","message":"This `mjml-python` library is a wrapper for a Rust implementation (MRML) and is distinct from another `mjml` package on PyPI, which is a pure Python port. Ensure you install `mjml-python` for the Rust-backed performance benefits.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consult the project's GitHub README for current limitations and supported features.","message":"The `mjml-python` library, while feature-rich, might not implement every single feature or component found in the official Node.js MJML implementation or other alternative Python ports. Always verify compatibility for advanced or less common MJML features.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Strictly validate and sanitize any untrusted user input before incorporating it into MJML templates.","message":"When using `mjml-python` with user-supplied MJML templates, be aware of potential cross-site scripting (XSS) vulnerabilities if untrusted data is directly inserted into the templates. Like HTML, MJML itself does not inherently sanitize all inputs, and custom HTML in `mj-raw` tags or other components could render scripts.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review `mjml-python` release notes and MRML changelogs when upgrading across `mjml-python` minor/major versions to identify any necessary adjustments to MJML templates or rendering options.","message":"The underlying MRML (Rust) library, which `mjml-python` wraps, undergoes major version bumps (e.g., v1.3.5 updated MRML to 5.0.0). While the `mjml-python` wrapper aims to maintain API stability, significant changes in MRML could potentially introduce subtle behavioral differences or require updates to MJML syntax expectations.","severity":"breaking","affected_versions":"Versions 1.3.5 and later (due to MRML 5.0.0 update), and future major MRML updates."}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}