email-html-mjml — Responsive Email Developer
Generate valid, cross-client MJML 4.x templates and compile them to production-ready HTML. The primary goal is compatibility: Outlook (2013–365), Gmail (web/app), Apple Mail, and major mobile clients. Every output must be compilable with
--config.validationLevel=strict
and survive Gmail's 102KB clip limit.
Workflow
Gather requirements
— Infer email type, brand colors, and content from the user's message and conversation context. Ask only for what is genuinely missing and blocking progress (e.g., no colors provided and the layout has branded sections). Never front-load a questionnaire.
Plan layout
— Decide and announce the structure before writing code (single-column, 2-col grid, hero + content, etc.)
Load component references
— Read the relevant file(s) from the Component Index below before writing any MJML
Generate MJML
— Write complete, valid MJML starting from
< mj-raw
< meta name = " color-scheme " content = " light dark "
< meta name = " supported-color-schemes " content = " light dark "
</ mj-raw
< mj-style inline = " inline "
.dark-logo { display: none !important; } </ mj-style
< mj-style
@media (prefers-color-scheme: dark) { .light-logo { display: none !important; } .dark-logo { display: block !important; } } </ mj-style
</ mj-head
Safe neutrals:
121212
(not
000000
) and
F1F1F1
(not
FFFFFF
) — prevents jarring forced inversions.
Accessibility Checklist
< mj-html-attributes
< mj-selector path = " .email-heading div "
< mj-html-attribute name = " role "
heading </ mj-html-attribute
< mj-html-attribute name = " aria-level "
1 </ mj-html-attribute
</ mj-selector
</ mj-html-attributes
< mj-text css-class = " email-heading " ...
Heading text </ mj-text
4.5:1 contrast ratio on all text/background pairs No text baked into images — always use live
blocks Component Index Before writing any MJML, read the component file(s) for the components you'll use. Group Components Load when File Head mj-attributes, mj-font, mj-style, mj-preview, mj-breakpoint, mj-html-attributes Setting up head, global styles components/head.md Layout mj-body, mj-section, mj-column, mj-group, mj-wrapper Building structure / grid components/layout.md Content mj-text, mj-image, mj-button, mj-divider, mj-spacer, mj-table Adding content blocks components/content.md Interactive mj-accordion, mj-carousel, mj-social, mj-navbar Interactive or social elements components/interactive.md Advanced mj-hero, mj-raw, mj-include Hero banners, template tags, partials components/advanced.md General reference (hierarchy, ending tags, validation, width math, Gmail clip): mjml-reference.md Compilation Read compilation.md for the full workflow. Key command: npx mjml template.mjml -o dist/template.html --config.minify = true --config.validationLevel = strict Hard rules: Never npm install -g mjml Always use npx or ./node_modules/.bin/mjml If mjml not in package.json , suggest npm install -D mjml Examples assets/examples/basic-layout.mjml — MJML docs basic layout example. Covers 6-section structure: company header, image hero + button, intro text, 2-column image+text, 3-column icons, social row. Intentionally bare-bones (no mj-head , no dark mode, placeholder copy) — reflects the MJML docs style. Use as a structural reference for layout patterns only, not as a production template. Output Always deliver: .mjml — complete MJML source (editable, version-controllable) .html — compiled output (production-ready, send via ESP) Name files after the email type: welcome.mjml , promo-sale.mjml , order-confirmation.mjml