Integrating MJML in your app couldn’t get easier: discover the MJML API 🔌

Nicolas Garnier
Feb 14, 2017 · 2 min read

While MJML has been making email developers happy for a year now, with an easy-to-use syntax and responsive-by-design markup, we don’t want to stop here.

Freeing you from the NodeJS dependency

Until today, because MJML is coded in NodeJS, if you wanted to integrate it in your app you had to run MJML on a NodeJS server yourself. While we love NodeJS, we understand that you might not know it or use a different language in your app.

Our objective: make this engine free from any dependency

This was also requested by our community on MJML’s Github but also led to questions on StackOverflow and we can understand it’s a fair request.

Making MJML language-agnostic for app integrations

Now, all it takes to render responsive HTML from MJML is a HTTP POST request to the MJML API, for example here in cURL:

POST request to the /render route on the MJML API

Here’s what the API will return, including possible errors and the version of MJML used:

Response from the /render POST request on the MJML API

Using MJML in JSON

While you are probably using MJML as a markup to code your emails, this API is using the JSON format. This was an easy decision as JSON is a standard format for APIs, being a fast, reliable and easy-to-use format.

This means that if you want to use MJML as a markup with the API, you need to escape your MJML string so it is JSON compliant. However, MJML can also be used in JSON, which is a format much easier to manipulate dynamically. You can know more about this in MJML’s documentation, but here’s what a MJML template looks like in JSON:

Example of a MJML template in JSON

Integrations all the way!

We’re proud to release the MJML API in public beta. To register, all you have to do is head over to https://mjml.io/api and click on “Join the beta”. A documentation is also available at https://mjml.io/api/documentation.

We hope you’ll love the API and use it to build awesome integrations. We already had requests for drag and drop builders, email test platforms and code editors. Hopefully, Litmus will even be able to use the API to support MJML in their builder, if you’d like so, upvote it in their roadmap!

Want to share what you built or need help? Join the team and the community on Slack, Twitter and always keep up to date by subscribing to the newsletter on https://mjml.io.

MJML: Making Responsive Email Easy

Stories and updates about mjml.

Nicolas Garnier

Written by

Making email cool @mailjet @mjmlio #emailgeeks

MJML: Making Responsive Email Easy

Stories and updates about mjml.