Skip to content
sumipost
Guides

MJML: what it is and why email teams use it.

The markup language that turns into email HTML, explained with real code.

What MJML does, how a document is built, how to write brand rules once, how to compile it, what changed in MJML 5 and where it stops.

Updated on sources read on 10/11/20267-minute read

What is MJML?

MJML (Mailjet Markup Language) is a markup language built to take the pain out of coding responsive email.1 Mailjet created it and it is published under the MIT licence: you can use it, change it and ship it in your own projects, commercial ones included.23

It looks like HTML, but the tags describe what you want: a section, a column, some text, a button. A compiler reads the .mjml file and writes the HTML that actually goes into the email, with the tables and inline styles that mail clients expect.

MJML doesn't send anything and isn't a service. It's a source format: you import the HTML it produces into whatever sending service you use.

Why use it instead of hand-written HTML?

Email HTML is not web HTML. Many mail clients ignore parts of modern CSS, and classic Outlook for Windows has rules of its own: no max-width outside tables, padding only on table cells, no media queries (the Outlook guide goes through them). That's why an email that holds up is still built from nested tables and conditional comments.

With MJML the compiler does that work. We compiled the sample on this page, and the HTML it produced contains:

  • tables marked role="presentation", so screen readers don't announce them as data tables;
  • fixed-width tables meant for Outlook, inside <!--[if mso | IE]> comments;
  • media queries that stack the columns below 480 pixels wide, the default value of mj-breakpoint;6
  • image widths in the width attribute as well as in the style.

The documentation says columns stack when the email is read on a phone, and that wrapping them in mj-group keeps them side by side.1

What does an MJML document look like?

A document starts with <mjml> and holds only two parts: <mj-head> for settings and <mj-body> for content.1 The body is 600 pixels wide unless you say otherwise.1

The most used components, from the official documentation
ComponentWhat it's for
mj-sectiona row of the email
mj-columna column inside a section; the space is split between the columns you declare
mj-texttext, with its styling
mj-imagea responsive image
mj-buttona button
mj-wrappergroups several sections, for example under one background
mj-heroan opening image that behaves like a section with a single column
mj-dividera horizontal rule
mj-spacerblank space
mj-rawHTML the compiler leaves as it is, unchecked

Here is a whole email: header, image, headline, text, button, a two-column row and a footer with the unsubscribe link. The brand, Studio Lume, is made up.

MJMLcompiled with MJML 4.18.0 in strict mode, 0 errors
<mjml lang="en">
  <mj-head>
    <mj-title>Three houses, one light</mj-title>
    <mj-preview>How we opened a 1930s house to the south.</mj-preview>
    <mj-attributes>
      <mj-all font-family="Manrope, 'Helvetica Neue', Arial, sans-serif" />
      <mj-text font-size="16px" line-height="26px" color="#1F2A2E" />
      <mj-button background-color="#1F2A2E" color="#FFFFFF"
        border-radius="0px" font-weight="700" />
      <mj-class name="headline" font-size="32px" line-height="38px"
        font-weight="300" />
    </mj-attributes>
  </mj-head>
  <mj-body width="600px" background-color="#EEF1EE">
    <mj-section background-color="#FFFFFF" padding="32px 24px 8px">
      <mj-column>
        <mj-text font-size="13px" font-weight="700"
          letter-spacing="4px">STUDIO LUME</mj-text>
      </mj-column>
    </mj-section>
    <mj-section background-color="#FFFFFF" padding="0 24px 24px">
      <mj-column>
        <mj-image src="https://www.example.com/img/house-1930.jpg"
          alt="The living room of the 1930s house, with light from the south" />
        <mj-text mj-class="headline" padding-top="24px">Three houses, one light</mj-text>
        <mj-text>How we opened a 1930s house to the south
          without touching its front.</mj-text>
        <mj-button href="https://www.example.com/projects/three-houses">
          Read the project</mj-button>
      </mj-column>
    </mj-section>
    <mj-section background-color="#FFFFFF" padding="0 24px 32px">
      <mj-column>
        <mj-text font-weight="700">The studio</mj-text>
        <mj-text>Who we are and how we work.</mj-text>
      </mj-column>
      <mj-column>
        <mj-text font-weight="700">The front</mj-text>
        <mj-text>Why we left it as it was.</mj-text>
      </mj-column>
    </mj-section>
    <mj-section padding="24px">
      <mj-column>
        <mj-text font-size="12px" line-height="18px" color="#4A5558">
          Studio Lume · a brand made up for this example.<br />
          You're receiving this email because you signed up on our site.
          <a href="https://www.example.com/unsubscribe"
            style="color:#1F2A2E">Unsubscribe</a>
        </mj-text>
      </mj-column>
    </mj-section>
  </mj-body>
</mjml>

Two details people often forget: mj-title is the title of the HTML document, and mj-preview is the text many mail clients show next to the subject line.

How do you write the brand rules once?

Inside mj-head, the mj-attributes block sets defaults: mj-all applies to every component, a tag such as mj-button applies to every button, and mj-class creates a named group of attributes you then apply with mj-class="headline".1

When the same attribute is set in several places, the one on the component wins, then the tag in mj-attributes, then mj-all, then MJML's default.1 In practice the brand rules live in the head and the body only carries the exceptions.

MJMLthe head of the sample, with a web font and classes
<mj-head>
  <mj-font name="Manrope"
    href="https://www.example.com/font/manrope.css" />
  <mj-attributes>
    <mj-all font-family="Manrope, 'Helvetica Neue', Arial, sans-serif" />
    <mj-text font-size="16px" line-height="26px" color="#1F2A2E" />
    <mj-button background-color="#1F2A2E" color="#FFFFFF"
      border-radius="0px" font-weight="700" inner-padding="14px 28px" />
    <mj-class name="titolo" font-size="32px" line-height="38px" font-weight="300" />
    <mj-class name="nota" font-size="12px" line-height="18px" color="#4A5558" />
  </mj-attributes>
</mj-head>

mj-font loads an external typeface only if the email uses it.1 In the compiled HTML, the link to the font sits inside <!--[if !mso]><!-->, so classic Outlook never loads it. That's why the fallback font stack matters as much as the main typeface. What to put in those rules, item by item, is in the email brand guidelines guide.

How do you compile MJML to HTML?

On the command line the basic command is mjml input.mjml -o output.html; -w watches the file and recompiles on every change, and --validate checks without generating anything.1

Shell
# install MJML in your project
npm install mjml

# compile a file to HTML
npx mjml newsletter.mjml -o newsletter.html

# recompile on every save
npx mjml -w newsletter.mjml -o newsletter.html

# check the file without generating anything
npx mjml --validate newsletter.mjml

From Node you call mjml2html. Since MJML 5 it is async: the mjml-core source declares it async, and the README calls it with await.62

JavaScript
import { readFile, writeFile } from "node:fs/promises";
import mjml2html from "mjml";

const source = await readFile("newsletter.mjml", "utf8");
// since MJML 5 the function is async: await works with version 4 too
const { html, errors } = await mjml2html(source, { validationLevel: "strict" });
await writeFile("newsletter.html", html);

If you don't want to install anything there is the official online editor,8 and for Visual Studio Code an extension from the MJML project with preview, linting and compiling.9

What does the compiler check?

MJML has three validation levels: skip doesn't check, soft reports errors but still generates, strict stops and generates nothing if it finds an error. The default is soft.1

It checks structure: a component where it can't go, an attribute that doesn't exist, a value in the wrong format. It won't tell you whether the email looks good, whether the colours have enough contrast or whether the image alt text makes sense. Those are questions for whoever reviews it.

What changed in MJML 5?

MJML 5.0.0 became stable on 16 April 2026; 5.4.1, the current release on the npm registry, followed on 10 September 2026. A 6.0.0-alpha.1 already exists, published on 9 October 2026 as experimental.4 The changes that matter to template authors:

  • mj-include is off by default. In Node you turn it back on with ignoreIncludes: false, on the command line with --config.allowIncludes true; the includePath option limits which folders can be included.25
  • The Node function is async: if you called mjml2html without await, your code has to change.6
  • Minification is new: it uses htmlnano and cssnano instead of the previous tools, and it is flagged as a breaking change.5
  • The generated <body> has an id, and the mj-body background colour now sits only on the inner div.5
  • Node 16 and 18 are no longer supported: you need 20, 22 or 24.5

We compiled the samples on this page with MJML 4.18.0, the version Sumipost's engine uses today. They don't use mj-include or minification, so none of the changes above affect them.

Where can you find MJML templates?

The MJML project keeps an official gallery of responsive templates, each with its source.7 They're a good way to see how an email is put together; to make one yours you change colours, typefaces, logo and copy, and it pays to do that in mj-attributes rather than component by component.

The Sumipost templates are MJML too: six layouts (welcome, newsletter, promotion, event, cart, greetings) that take on the style of a brand read from its website, and export as MJML, HTML or a ZIP with the images.

Where does MJML stop?

MJML generates code that holds up in most mail clients, but it can't change what a client is able to do. The documentation itself lists some limits:

  • with a background image on mj-section, background-size and background-position are limited in desktop Outlook, and without background-size the no-repeat value is ignored;1
  • if you set background-url on mj-wrapper, you can't set another one on a child section: desktop Outlook doesn't support it;1
  • in the mj-button compatibility table, corner radius is not supported in Outlook for Windows from 2016 to 2024: the button stays square there.10

Then there are things MJML doesn't decide for you: dark mode, colour contrast, alt text, image file size. And mj-raw passes HTML through untouched, so compatibility becomes your problem again.

Frequently asked questions

Is MJML free?

Yes. MJML is open source under the MIT licence: you can use it, change it and ship it in your own projects, commercial ones included, as long as you keep the copyright notice and the licence.

Can I import MJML straight into my sending service?

It depends on the service. MJML is a source format: what lands in the inbox is the HTML it compiles to. If your service doesn't import MJML, compile the file and import the HTML.

What is the difference between MJML 4 and MJML 5?

MJML 5, stable since 16 April 2026, turns mj-include off by default, makes the Node function mjml2html async, changes minification and needs Node 20 or later.

Does MJML fix Outlook problems?

Many of them, because it generates the tables and conditional comments for classic Outlook on its own. Not all: rounded button corners and some background settings stay limited, as its own documentation says.

What is the default width of an MJML email?

600 pixels: that is the default width attribute of mj-body. Below a 480 pixel screen width the columns stack, because 480px is the default value of mj-breakpoint.

Does Sumipost use MJML?

Yes. Sumipost builds emails and templates in MJML and exports them as MJML, HTML or a ZIP with the images. Sumipost does not send email: you import the file into the sending service you already use.

Sources

These are the sources we read to write this guide, with the date we read them. If one changes, we update the guide at this same address.

  1. MJML, official documentation. documentation.mjml.io, read on 10/11/2026.
  2. MJML, official repository and README. github.com/mjmlio/mjml, read on 10/11/2026.
  3. MJML, MIT licence (LICENSE.md). github.com/mjmlio/mjml/blob/master/LICENSE.md, read on 10/11/2026.
  4. npm registry entry for the mjml package: versions and dates. registry.npmjs.org/mjml, read on 10/11/2026.
  5. MJML 5.0.0 release notes. github.com/mjmlio/mjml/releases/tag/v5.0.0, read on 10/11/2026.
  6. mjml-core source (index.js): the default breakpoint and the async mjml2html function. github.com/mjmlio/mjml/blob/master/packages/mjml-core/src/index.js, read on 10/11/2026.
  7. MJML, official template gallery. mjml.io/templates, read on 10/11/2026.
  8. MJML, official online editor. mjml.io/try-it-live, read on 10/11/2026.
  9. MJML, official Visual Studio Code extension. github.com/mjmlio/vscode-mjml, read on 10/11/2026.
  10. MJML, mj-button client compatibility (updated 26/09/2025). mjml.io/compatibility/mj-button, read on 10/11/2026.