MJML: the only framework that makes responsive-email easy
Installations
npm install mjml-head-title
Developer
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
No
Node Version
18.11.0
NPM Version
lerna/3.22.1/node@v18.11.0+arm64 (darwin)
Statistics
17,107 Stars
2,421 Commits
964 Forks
168 Watching
25 Branches
162 Contributors
Updated on 28 Nov 2024
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
92,060,913
Last day
-5.6%
120,812
Compared to previous day
Last week
-0.2%
673,895
Compared to previous week
Last month
8.4%
2,850,037
Compared to previous month
Last year
24%
29,796,783
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
3
Dev Dependencies
2
MJML 4
If you're looking for MJML 3.3.X check this branch
| Translated documentation | Introduction | Installation | Usage |
Translated documentation
Language | Link 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.
1npm install mjml
Development
To work on MJML, make changes and create merge requests, download and install yarn for easy development.
1git clone https://github.com/mjmlio/mjml.git && cd mjml 2yarn 3yarn 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!
Applications and plugins
MJML comes with an ecosystem of tools and plugins, check out:
- The MJML App (MJML is included)
- Visual Studio Code plugin (MJML is included)
- Sublime Text plugin (MJML needs to be installed separately)
For more tools, check the Community page.
Command line interface
Compiles the file and outputs the HTML generated in
output.html
1mjml input.mjml -o output.html
You can pass optional arguments
to the CLI and combine them.
argument | description | default value |
---|---|---|
mjml -m [input] | Migrates a v3 MJML file to the v4 syntax | NA |
mjml [input] -o [output] | Writes the output to [output] | NA |
mjml [input] -s | Writes the output to stdout | NA |
mjml -w [input] | Watches the changes made to [input] (file or folder) | NA |
mjml [input] --config.beautify | Beautifies the output (true or false ) | true |
mjml [input] --config.minify | Minifies the output (true or false ) | false |
See mjml-cli documentation for more information about config options.
Inside Node.js
1import mjml2html from 'mjml' 2 3/* 4 Compile an mjml string 5*/ 6const htmlOutput = mjml2html(` 7 <mjml> 8 <mj-body> 9 <mj-section> 10 <mj-column> 11 <mj-text> 12 Hello World! 13 </mj-text> 14 </mj-column> 15 </mj-section> 16 </mj-body> 17 </mjml> 18`, options) 19 20 21/* 22 Print the responsive HTML generated and MJML errors if any 23*/ 24console.log(htmlOutput)
You can pass optional options
as an object to the mjml2html
function:
option | unit | description | default value |
---|---|---|---|
fonts | object | Default fonts imported in the HTML rendered by MJML | See in index.js |
keepComments | boolean | Option to keep comments in the HTML output | true |
ignoreIncludes | boolean | Option to ignore mj-includes | false |
beautify | boolean | Option to beautify the HTML output | false |
minify | boolean | Option to minify the HTML output | false |
validationLevel | string | Available values for the validator: 'strict', 'soft', 'skip' | 'soft' |
filePath | string | Path of file, used for relative paths in mj-includes | '.' |
preprocessors | array of functions | Preprocessors applied to the xml before parsing. Input must be xml, not json. Functions must be (xml: string) => string | [] |
juicePreserveTags | Preserve some tags when inlining css, see mjml-cli documentation for more info | NA | |
minifyOptions | Options for html minifier, see mjml-cli documentation for more info | NA | |
mjmlConfigPath | string | The path or directory of the .mjmlconfig file (for custom components use) | process.cwd() |
useMjmlConfigOptions | Allows to use the options attribute from .mjmlconfig file | false |
Client-side (in browser)
1var mjml2html = require('mjml-browser') 2 3/* 4 Compile a mjml string 5*/ 6var htmlOutput = mjml2html(` 7 <mjml> 8 <mj-body> 9 <mj-section> 10 <mj-column> 11 <mj-text> 12 Hello World! 13 </mj-text> 14 </mj-column> 15 </mj-section> 16 </mj-body> 17 </mjml> 18`, options) 19 20 21/* 22 Print the responsive HTML generated and MJML errors if any 23*/ 24console.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
No vulnerabilities found.
Reason
1 commit(s) and 14 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE.md:0
- Info: FSF or OSI recognized license: MIT License: LICENSE.md:0
Reason
Found 17/26 approved changesets -- score normalized to 6
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/build-documentation.yml:1
- Warn: no topLevel permission defined: .github/workflows/mjml-workflow.yml:1
- Info: no jobLevel write permissions found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/build-documentation.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/mjmlio/mjml/build-documentation.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/mjml-workflow.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/mjmlio/mjml/mjml-workflow.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/mjml-workflow.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/mjmlio/mjml/mjml-workflow.yml/master?enable=pin
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 third-party GitHubAction dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 25 are checked with a SAST tool
Reason
39 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-434g-2637-qmqr
- Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m
- Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw
- Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p
- Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747
- Warn: Project is vulnerable to: GHSA-pfq8-rq6v-vf5m
- Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g
- Warn: Project is vulnerable to: GHSA-3j8f-xvm3-ffx4
- Warn: Project is vulnerable to: GHSA-4p35-cfcx-8653
- Warn: Project is vulnerable to: GHSA-7f3x-x4pr-wqhj
- Warn: Project is vulnerable to: GHSA-jpp7-7chh-cf67
- Warn: Project is vulnerable to: GHSA-q6wq-5p59-983w
- Warn: Project is vulnerable to: GHSA-j9fq-vwqv-2fm2
- Warn: Project is vulnerable to: GHSA-pqw5-jmp5-px4v
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-h9rv-jmmf-4pgx
- Warn: Project is vulnerable to: GHSA-hxcc-f52p-wc94
- Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9
- Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw
- Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc
- Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh
- Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-7p7h-4mm5-852v
- Warn: Project is vulnerable to: GHSA-38fc-wpqx-33j7
Score
4
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More