Welcome to MJNML - a minimal MJML parser API that converts MJML templates into responsive HTML email code.
MJNML is a simple Express API server that parses MJML (Mailjet Markup Language) templates and returns the HTML output. It provides a straightforward way to convert your MJML templates into responsive HTML email code through a REST API.
POST /v1/render
Converts MJML markup to HTML.
{
"mjml": "<mjml><mj-body><mj-section><mj-column><mj-text>Hello, World!</mj-text></mj-column></mj-section></mj-body></mjml>"
}
{
"errors": [],
"html": "\n[...]\n ",
"mjml": "Hello, World! ",
"mjml_version": "4.15.3"
}
GET /v1/health
Check if the API is running properly.
{
"status": "OK",
"message": "mjnml MJML API is running"
}
curl -X POST https://mjnml.private.coffee/v1/render \
-H "Content-Type: application/json" \
-d '{"mjml": "<mjml><mj-body><mj-section><mj-column><mj-text>Hello, World!</mj-text></mj-column></mj-section></mj-body></mjml>"}'
fetch('https://mjnml.private.coffee/v1/render', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
mjml: '<mjml><mj-body><mj-section><mj-column><mj-text>Hello, World!</mj-text></mj-column></mj-section></mj-body></mjml>'
}),
})
.then(response => response.json())
.then(data => {
console.log(data.html);
})
.catch((error) => {
console.error('Error:', error);
});
If you want to set up your own instance of MJNML, you can install it from the repository or npm:
git clone https://git.private.coffee/PrivateCoffee/mjnml.git
cd mjnml
npm install
npm start
npx mjnml-api
Use the PORT
environment variable to specify the port the server should listen on.