mjml vs mjml-cli vs mjml-core vs mjml-react
Email Template Frameworks
mjmlmjml-climjml-coremjml-reactSimilar Packages:

Email Template Frameworks

MJML is a markup language designed to reduce the pain of coding responsive email. It abstracts the complexities of email client compatibility and provides a straightforward way to create responsive email templates. The MJML ecosystem consists of several packages that cater to different needs, from rendering MJML to HTML to integrating with React applications, making it versatile for various development workflows.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
mjml017,8948.97 kB692 months agoMIT
mjml-cli017,89428.3 kB692 months agoMIT
mjml-core017,89459.8 kB692 months agoMIT
mjml-react0999267 kB3-MIT

Feature Comparison: mjml vs mjml-cli vs mjml-core vs mjml-react

Rendering Method

  • mjml:

    MJML provides a straightforward way to write responsive email templates using a markup language that is easy to understand and use. It compiles into HTML that is optimized for various email clients, ensuring compatibility and responsiveness.

  • mjml-cli:

    MJML-CLI allows you to compile MJML files into HTML via the command line, making it suitable for batch processing and automation in build scripts. This is particularly useful for developers who prefer command-line tools for efficiency.

  • mjml-core:

    MJML-Core enables developers to use MJML rendering capabilities programmatically within JavaScript applications. This allows for dynamic email generation based on application state or user data, providing flexibility in email content creation.

  • mjml-react:

    MJML-React integrates MJML directly into React components, allowing developers to use MJML syntax within their JSX. This promotes a seamless development experience for React applications, enabling the use of responsive email templates as part of the component architecture.

Integration

  • mjml:

    MJML can be integrated into any web project, allowing developers to create responsive email templates without worrying about the underlying HTML structure. It is a standalone solution that can be used in various environments.

  • mjml-cli:

    MJML-CLI is designed for integration with build tools and CI/CD pipelines, allowing for automated email template compilation as part of the deployment process. This makes it easier to manage email templates in larger projects.

  • mjml-core:

    MJML-Core is suitable for developers looking to integrate MJML rendering directly into their applications, providing a way to generate email content dynamically based on application logic.

  • mjml-react:

    MJML-React is specifically designed for React applications, allowing developers to use MJML components as part of their React component tree. This makes it easy to manage email templates alongside other UI components.

Ease of Use

  • mjml:

    MJML's syntax is designed to be intuitive and easy to learn, making it accessible for developers who may not be experts in HTML and CSS. This lowers the barrier to entry for creating responsive emails.

  • mjml-cli:

    MJML-CLI is easy to use for those familiar with command-line tools. It provides a simple interface for compiling MJML files, making it straightforward to integrate into existing workflows.

  • mjml-core:

    MJML-Core requires some understanding of JavaScript, but it offers powerful capabilities for programmatic email generation. It is suitable for developers comfortable with coding in JavaScript.

  • mjml-react:

    MJML-React leverages the familiar React component model, making it easy for React developers to adopt MJML without learning a new syntax. This enhances productivity and reduces the learning curve.

Community and Support

  • mjml:

    MJML has an active community and extensive documentation, making it easy to find resources and support. This is beneficial for developers looking for help or examples when creating email templates.

  • mjml-cli:

    As part of the MJML ecosystem, MJML-CLI benefits from the same community support and documentation, ensuring that users can find help when needed.

  • mjml-core:

    MJML-Core is well-documented, and its integration into JavaScript applications is supported by a growing community. Developers can find examples and use cases to guide their implementation.

  • mjml-react:

    MJML-React is supported by the React community, and developers can find numerous resources on integrating MJML with React. This enhances the overall support available for using MJML in React applications.

Performance

  • mjml:

    MJML compiles templates into optimized HTML, which is crucial for email performance. The resulting HTML is designed to minimize rendering issues across various email clients, ensuring a smooth user experience.

  • mjml-cli:

    Using MJML-CLI can improve performance in build processes by allowing batch compilation of MJML files, reducing the time spent on manual compilation and ensuring consistency across email templates.

  • mjml-core:

    MJML-Core allows for efficient email generation in applications, as it can render templates on-the-fly based on user data or application state, optimizing the performance of dynamic email content.

  • mjml-react:

    MJML-React ensures that email templates are rendered efficiently within React applications, leveraging React's rendering optimizations to minimize performance overhead when generating email content.

How to Choose: mjml vs mjml-cli vs mjml-core vs mjml-react

  • mjml:

    Choose MJML if you want a simple way to write responsive email templates using a declarative syntax. It is ideal for developers who prefer a markup language over raw HTML and CSS.

  • mjml-cli:

    Choose MJML-CLI if you need a command-line interface to compile MJML files into HTML. This is useful for automation in build processes or when integrating MJML into CI/CD pipelines.

  • mjml-core:

    Choose MJML-Core if you want to integrate MJML rendering capabilities directly into your JavaScript applications. It allows for programmatic access to MJML's features without relying on a command line.

  • mjml-react:

    Choose MJML-React if you are building a React application and want to render MJML components directly within your React components. This is beneficial for maintaining a consistent component structure and leveraging React's ecosystem.

README for mjml

MJML 4

github actions

| Introduction | Installation | Usage | Contribute |


Introduction

MJML is a markup language created by Mailjet and designed to reduce the pain of coding a responsive email. Its semantic syntax makes it easy and straightforward while its rich standard components library fastens 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

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

Note that it's also possible to define preprocessors in your mjmlconfig file. For this, you need to use a .mjmlconfig.js file. This js file needs to export an Object with the same structure as a standard JSON .mjmlconfig file.

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.