Node.js wrapper for
Switch branches/tags
Nothing to show
Clone or download
Latest commit 2a2c1b0 Apr 25, 2016
Failed to load latest commit information.
.gitignore Updating .gitignore to latest standard Jun 27, 2014
LICENSE Updating license for 2016 Apr 25, 2016 Cleaning up examples Apr 25, 2016
package.json v1.0.4 Apr 25, 2016
premailer.js Fixing code consistency issues Apr 25, 2016


A simple api wrapper for, a great tool for inlining css before you send an email.

node-premailer simplifies api integration by calling the Premailer API to inline css styles (and other options such as removing comments, classes and ids), then retrieving the generated html and text from their respective URLs before passing them to your callback.


  npm install premailer-api

Or from source:

  git clone git://
  cd node-premailer
  npm link


var premailer = require('premailer-api');

var emailTemplate = `
      <title>My Email</title>
      <style type="text/css">
        a { color: #336699; }
      Styles inlined with
      <a href="">Premailer</a> via
      <a href="">node-premailer</a>.

premailer.prepare({ html: emailTemplate }, function (err, email) {
  if (err) throw err;


  • premailerAPI (string) The URL of the premailer API. If you're running your own, replace this. Defaults to
  • html (string) The html of the email to parse and inline styles.
  • url (string) The url of the email to fetch then parse and inline styles.
  • fetchHTML (boolean) Whether to fetch the parsed HTML (you'll usually want this). Defaults to true.
  • fetchText (boolean) Whether to fetch the auto-generated text version (disable this if you are providing your own). Defaults to true.
  • See for full list of options. All options have aliases for node.js style variable names.
    • adapter
    • baseUrl || base_url
    • lineLength || line_length
    • linkQueryString || link_query_string
    • preserveStyles || preserve_styles
    • removeIds || remove_ids
    • removeClasses || remove_classes
    • removeComments || remove_comments

License and Credits

MIT Licensed. Copyright Jed Watson 2016.

A big thank you to Dialect for Premailer, and for making the API freely available.

There's also a web version available here:

And you can check out the source code for Premailer itself here: