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
mjml018,05215 kB692 days agoMIT
mjml-cli018,05232.2 kB692 days agoMIT
mjml-core018,05287.8 kB692 days agoMIT
mjml-react01,000267 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

Developed by


github actions

| Introduction | Installation | Usage |


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

Usage

Online

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

try it live

Applications and plugins

MJML comes with 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 [input] -o [output]Writes the output to [output]
mjml [input] -sWrites the output to stdout
mjml [input] -s --noStdoutFileCommentWrites the output to stdout without file comment in the first line
mjml -w [input]Watches the changes made to [input] (file or folder)
mjml [input] --config.allowIncludesEnables mj-include processing (true or false)false
mjml [input] --config.allowMixedSyntaxAllows mixing block and CSS variable syntax when sanitizeStyles is enabled (true or false)false
mjml [input] --config.beautifyBeautifies the output (true or false)true
mjml [input] --config.includePathAdds allowlisted include root(s), as a string path or JSON array of paths
mjml [input] --config.minifyMinifies the output (true or false)false
mjml [input] --config.minifyOptionsOptions for HTML minifier, use minifyCss to control CSS minificationSee mjml-cli documentation
mjml [input] --config.juicePreserveTagsPreserve some tags when inlining CSSSee mjml-cli documentation
mjml [input] --config.mjmlConfigPathPath to .mjmlconfig file for custom componentscurrent working directory
mjml [input] --config.sanitizeStylesSanitizes template variables inside CSS before minification (true or false)false
mjml [input] --config.useMjmlConfigOptionsAllows to use the options attribute from .mjmlconfig filefalse
mjml [input] --config.templateSyntaxSets custom template delimiters as JSON array ([{"prefix":"{{","suffix":"}}"}])[{"prefix":"{{","suffix":"}}"},{"prefix":"[[","suffix":"]]"}]

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

Inside Node.js

import mjml2html from 'mjml'

/*
  Compile an mjml string
*/
async function renderMjml() {
  const htmlOutput = await 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)
}

renderMjml()

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

optionunitdescriptiondefault value
allowMixedSyntaxbooleanAllows mixed block/value/property template syntaxes during CSS sanitizationfalse
beautifybooleanOption to beautify the HTML outputfalse
filePathstringPath of file, used for relative paths in mj-include instances.
fontsobjectDefault fonts imported in the HTML rendered by MJMLSee in index.js
ignoreIncludesbooleanOption to ignore mj-include instancestrue
includePathstring or string[]Additional allowlisted include root(s), used when ignoreIncludes is false
juicePreserveTagsobjectPreserve some tags when inlining CSS, see documentation for more info
keepCommentsbooleanOption to keep comments in the HTML outputtrue
minifybooleanOption to minify the HTML outputfalse
minifyOptionsobjectOptions for htmlnano minification (including minifyCss), see documentation for more info
mjmlConfigPathstringThe path or directory of the .mjmlconfig file (for custom components use)process.cwd()
preprocessorsarray of functionsPreprocessors applied to the xml before parsing. Input must be xml, not json. Functions must be (xml: string) => string[]
sanitizeStylesbooleanSanitizes template variables in CSS before minificationfalse
templateSyntaxarray of objectsCustom template delimiters used by sanitization ([{ prefix, suffix }])[{"prefix":"{{","suffix":"}}"},{"prefix":"[[","suffix":"]]"}]
useMjmlConfigOptionsbooleanAllows to use the options attribute from .mjmlconfig filefalse
validationLevelstringAvailable values for the validator: strict, soft, skipsoft.

Client-side (in browser)

var mjml2html = require('mjml-browser')

/*
  Compile a mjml string
*/
mjml2html(`
  <mjml>
    <mj-body>
      <mj-section>
        <mj-column>
          <mj-text>
            Hello World!
          </mj-text>
        </mj-column>
      </mj-section>
    </mj-body>
  </mjml>
`, options).then(function (htmlOutput) {
  /*
    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.