Convert Figma logo to code with AI

mjmlio logomjml

MJML: the only framework that makes responsive-email easy

16,905
951
16,905
76

Top Related Projects

A free simple responsive HTML email template

A few simple, but solid patterns for responsive HTML email templates and newsletters. Even in Outlook and Gmail.

Quickly create responsive HTML emails that work on any device and client. Even Outlook.

Rock-solid transactional email templates for applications.

Email Blueprints is a collection of HTML email templates that can serve as a solid foundation and starting point for the design of emails

Quickly build HTML emails with Tailwind CSS.

Quick Overview

MJML is an open-source markup language designed to make responsive email coding easy. It abstracts away the complex HTML and CSS required to build responsive emails, allowing developers to focus on the structure and content of their messages.

Pros

  • Responsive by Design: MJML is built with responsive design in mind, making it easy to create emails that look great on any device.
  • Simplified Syntax: MJML's simplified syntax and components make it easier to write and maintain email templates compared to traditional HTML and CSS.
  • Extensive Component Library: MJML comes with a wide range of pre-built components, such as headers, footers, and content blocks, that can be easily customized.
  • Active Community: MJML has a large and active community of developers who contribute to the project, provide support, and create additional components.

Cons

  • Learning Curve: Developers who are new to MJML may need to invest time in learning the syntax and component structure.
  • Limited Browser Support: MJML-generated emails may not be compatible with older email clients that do not support modern HTML and CSS features.
  • Vendor Lock-in: Developers who use MJML may become dependent on the project and have difficulty transitioning to other email development tools.
  • Performance Overhead: The MJML compiler adds an additional step to the email development process, which may impact performance for large or complex email templates.

Code Examples

Here are a few examples of MJML code:

<mjml>
  <mj-body>
    <mj-section>
      <mj-column>
        <mj-text>
          Hello, world!
        </mj-text>
      </mj-column>
    </mj-section>
  </mj-body>
</mjml>

This code creates a simple email with a single section and a centered text element.

<mjml>
  <mj-body>
    <mj-section background-color="#f0f0f0">
      <mj-column>
        <mj-text font-size="20px" color="#333333" padding="20px">
          Welcome to our newsletter!
        </mj-text>
        <mj-divider border-color="#cccccc" />
        <mj-text font-size="16px" color="#666666" padding="20px">
          In this issue, we'll be covering the latest news and updates from our company.
        </mj-text>
      </mj-column>
    </mj-section>
  </mj-body>
</mjml>

This code creates a section with a gray background, a welcome message, a divider, and a description of the newsletter content.

<mjml>
  <mj-body>
    <mj-section>
      <mj-column width="50%">
        <mj-image src="https://example.com/logo.png" alt="Company Logo" />
      </mj-column>
      <mj-column width="50%">
        <mj-text align="right" font-size="24px" color="#333333" padding="20px">
          Our Company
        </mj-text>
      </mj-column>
    </mj-section>
  </mj-body>
</mjml>

This code creates a section with two columns: one for a logo image and one for a company name.

Getting Started

To get started with MJML, follow these steps:

  1. Install the MJML command-line interface (CLI) using npm:

    npm install -g mjml
    
  2. Create a new MJML file, for example, example.mjml:

    <mjml>
      <mj-body>
        <mj-section>
          <mj-column>
            <mj-text>
              Hello, world!
            </mj-text>
          </mj-column>
        </mj-section>
      </mj-body>
    </mjml>
    
  3. Compile the MJML file to HTML using the CLI:

    mjml
    

Competitor Comparisons

A free simple responsive HTML email template

Pros of responsive-html-email-template

  • Simpler and more lightweight, requiring less setup and dependencies
  • Provides a basic, ready-to-use template for quick implementation
  • Easier to customize directly in HTML for developers familiar with traditional email coding

Cons of responsive-html-email-template

  • Less feature-rich compared to MJML's component-based system
  • Requires more manual work for complex layouts and designs
  • Limited to a single template, whereas MJML offers more flexibility and reusable components

Code Comparison

responsive-html-email-template:

<table role="presentation" border="0" cellpadding="0" cellspacing="0" class="body">
  <tr>
    <td>&nbsp;</td>
    <td class="container">
      <div class="content">
        <!-- START CENTERED WHITE CONTAINER -->
        <table role="presentation" class="main">

MJML:

<mjml>
  <mj-body>
    <mj-section>
      <mj-column>
        <mj-text>
          Hello World!
        </mj-text>
      </mj-column>
    </mj-section>
  </mj-body>
</mjml>

The responsive-html-email-template uses traditional HTML table-based structure, while MJML employs a custom XML-like syntax with pre-defined components. MJML's approach simplifies the creation of complex, responsive email layouts, but requires learning its specific syntax and using its compiler. The responsive-html-email-template offers a more familiar HTML structure but demands more manual coding for responsiveness and cross-client compatibility.

A few simple, but solid patterns for responsive HTML email templates and newsletters. Even in Outlook and Gmail.

Pros of Cerberus

  • Lightweight and simple, with a focus on basic responsive email templates
  • Easier to understand and customize for developers familiar with traditional HTML/CSS
  • Requires no build process or additional tools to use

Cons of Cerberus

  • Limited set of pre-built components compared to MJML
  • Lacks a comprehensive framework for creating complex email layouts
  • May require more manual coding and testing for cross-client compatibility

Code Comparison

MJML:

<mjml>
  <mj-body>
    <mj-section>
      <mj-column>
        <mj-text>Hello World</mj-text>
      </mj-column>
    </mj-section>
  </mj-body>
</mjml>

Cerberus:

<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
  <tr>
    <td style="padding: 20px 0; text-align: center">
      Hello World
    </td>
  </tr>
</table>

MJML uses a custom XML-like syntax with predefined components, while Cerberus relies on traditional HTML tables for layout. MJML abstracts away much of the complexity of email HTML, whereas Cerberus provides a more direct approach to structuring email content.

Quickly create responsive HTML emails that work on any device and client. Even Outlook.

Pros of Foundation for Emails

  • More comprehensive framework with additional UI components and layouts
  • Integrates well with other Foundation projects for a cohesive ecosystem
  • Extensive documentation and community support

Cons of Foundation for Emails

  • Steeper learning curve due to more complex syntax and structure
  • Less focused on email-specific features compared to MJML
  • Requires more setup and configuration for email-specific use cases

Code Comparison

MJML:

<mjml>
  <mj-body>
    <mj-section>
      <mj-column>
        <mj-text>Hello World</mj-text>
      </mj-column>
    </mj-section>
  </mj-body>
</mjml>

Foundation for Emails:

<container>
  <row>
    <columns>
      <p>Hello World</p>
    </columns>
  </row>
</container>

Both frameworks aim to simplify responsive email design, but MJML focuses specifically on email development with a more intuitive syntax. Foundation for Emails offers a broader set of features as part of a larger framework, which can be beneficial for projects that extend beyond email templates. MJML's email-centric approach may lead to quicker development and easier maintenance for email-specific projects, while Foundation for Emails provides more flexibility for complex layouts and integration with other Foundation components.

Rock-solid transactional email templates for applications.

Pros of postmark-templates

  • Ready-to-use, professionally designed email templates
  • Focused on transactional emails, ideal for specific use cases
  • Easily customizable with minimal HTML knowledge

Cons of postmark-templates

  • Limited to a specific set of templates, less flexibility
  • Requires manual editing for customization
  • No built-in responsive design framework

Code Comparison

postmark-templates:

<table class="email-content" width="100%" cellpadding="0" cellspacing="0">
  <tr>
    <td class="email-body" width="100%" cellpadding="0" cellspacing="0">
      <table class="email-body_inner" align="center" width="570" cellpadding="0" cellspacing="0">
        <!-- Email content here -->
      </table>
    </td>
  </tr>
</table>

mjml:

<mjml>
  <mj-body>
    <mj-section>
      <mj-column>
        <!-- Email content here -->
      </mj-column>
    </mj-section>
  </mj-body>
</mjml>

mjml offers a more abstracted and simplified syntax for creating responsive emails, while postmark-templates uses traditional HTML tables for layout. mjml provides a more robust framework for creating custom designs, whereas postmark-templates offers pre-designed templates for quick implementation of common email types.

Email Blueprints is a collection of HTML email templates that can serve as a solid foundation and starting point for the design of emails

Pros of email-blueprints

  • Provides ready-to-use templates for various email types
  • Includes responsive designs for mobile compatibility
  • Offers a collection of modular, reusable components

Cons of email-blueprints

  • Less actively maintained compared to MJML
  • Requires more manual coding and customization
  • Limited documentation and community support

Code Comparison

email-blueprints:

<table border="0" cellpadding="0" cellspacing="0" width="100%">
  <tr>
    <td style="padding: 10px 0 30px 0;">
      <table align="center" border="0" cellpadding="0" cellspacing="0" width="600">
        <!-- Content goes here -->
      </table>
    </td>
  </tr>
</table>

MJML:

<mjml>
  <mj-body>
    <mj-section>
      <mj-column>
        <!-- Content goes here -->
      </mj-column>
    </mj-section>
  </mj-body>
</mjml>

MJML offers a more abstracted and simplified syntax, reducing the need for complex table structures. This makes it easier to create and maintain responsive email templates compared to the traditional HTML approach used in email-blueprints.

Quickly build HTML emails with Tailwind CSS.

Pros of Maizzle

  • Utilizes Tailwind CSS for rapid, utility-first styling
  • Offers more flexibility and customization options
  • Supports PostCSS plugins for advanced CSS processing

Cons of Maizzle

  • Steeper learning curve, especially for those unfamiliar with Tailwind CSS
  • Less extensive documentation compared to MJML
  • Smaller community and ecosystem

Code Comparison

MJML:

<mjml>
  <mj-body>
    <mj-section>
      <mj-column>
        <mj-text>Hello World</mj-text>
      </mj-column>
    </mj-section>
  </mj-body>
</mjml>

Maizzle:

<table>
  <tr>
    <td class="px-4 py-8">
      <p class="text-base">Hello World</p>
    </td>
  </tr>
</table>

Summary

MJML offers a more straightforward approach with its custom XML-like syntax, making it easier for beginners to create responsive emails. Maizzle, on the other hand, provides greater flexibility and customization options by leveraging Tailwind CSS and modern web development tools. While MJML has a larger community and more comprehensive documentation, Maizzle appeals to developers who prefer a utility-first CSS approach and want more control over their email templates.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

MJML 4

If you're looking for MJML 3.3.X check this branch

github actions

| Translated documentation | Introduction | Installation | Usage |


Translated documentation

LanguageLink for documentation
日本語日本語ドキュメント

Introduction

MJML is a markup language created by Mailjet and designed to reduce the pain of coding a responsive email. Its semantic syntax makes the language easy and straightforward while its rich standard components library shortens your development time and lightens your email codebase. MJML’s open-source engine takes care of translating the MJML you wrote into responsive HTML.

Installation

You can install MJML with NPM to use it with NodeJS or the Command Line Interface. If you're not sure what those are, head over to Usage for other ways to use MJML.

npm install mjml

Development

To work on MJML, make changes and create merge requests, download and install yarn for easy development.

git clone https://github.com/mjmlio/mjml.git && cd mjml
yarn
yarn build

You can also run yarn build:watch to rebuild the package as you code.

Usage

Online

Don't want to install anything? Use the free online editor!

try it live


Applications and plugins

MJML comes with an ecosystem of tools and plugins, check out:

For more tools, check the Community page.

Command line interface

Compiles the file and outputs the HTML generated in output.html

mjml input.mjml -o output.html

You can pass optional arguments to the CLI and combine them.

argumentdescriptiondefault value
mjml -m [input]Migrates a v3 MJML file to the v4 syntaxNA
mjml [input] -o [output]Writes the output to [output]NA
mjml [input] -sWrites the output to stdoutNA
mjml -w [input]Watches the changes made to [input] (file or folder)NA
mjml [input] --config.beautifyBeautifies the output (true or false)true
mjml [input] --config.minifyMinifies the output (true or false)false

See mjml-cli documentation for more information about config options.

Inside Node.js

import mjml2html from 'mjml'

/*
  Compile an mjml string
*/
const htmlOutput = mjml2html(`
  <mjml>
    <mj-body>
      <mj-section>
        <mj-column>
          <mj-text>
            Hello World!
          </mj-text>
        </mj-column>
      </mj-section>
    </mj-body>
  </mjml>
`, options)


/*
  Print the responsive HTML generated and MJML errors if any
*/
console.log(htmlOutput)

You can pass optional options as an object to the mjml2html function:

optionunitdescriptiondefault value
fontsobjectDefault fonts imported in the HTML rendered by MJMLSee in index.js
keepCommentsbooleanOption to keep comments in the HTML outputtrue
ignoreIncludesbooleanOption to ignore mj-includesfalse
beautifybooleanOption to beautify the HTML outputfalse
minifybooleanOption to minify the HTML outputfalse
validationLevelstringAvailable values for the validator: 'strict', 'soft', 'skip''soft'
filePathstringPath of file, used for relative paths in mj-includes'.'
preprocessorsarray of functionsPreprocessors applied to the xml before parsing. Input must be xml, not json. Functions must be (xml: string) => string[]
juicePreserveTagsPreserve some tags when inlining css, see mjml-cli documentation for more infoNA
minifyOptionsOptions for html minifier, see mjml-cli documentation for more infoNA
mjmlConfigPathstringThe path or directory of the .mjmlconfig file (for custom components use)process.cwd()
useMjmlConfigOptionsAllows to use the options attribute from .mjmlconfig filefalse

Client-side (in browser)

var mjml2html = require('mjml-browser')

/*
  Compile a mjml string
*/
var htmlOutput = mjml2html(`
  <mjml>
    <mj-body>
      <mj-section>
        <mj-column>
          <mj-text>
            Hello World!
          </mj-text>
        </mj-column>
      </mj-section>
    </mj-body>
  </mjml>
`, options)


/*
  Print the responsive HTML generated and MJML errors if any
*/
console.log(htmlOutput)

API

A free-to-use MJML API is available to make it easy to integrate MJML in your application. Head over here to learn more about the API.

MJML Slack

MJML wouldn't be as cool without its amazing community. Head over the Community Slack to meet fellow MJML'ers.

Contributors

NPM DownloadsLast 30 Days