Word Cloud Creator

Romain Vialard, Oct 2012

This library provides one single method to create an HTML Word Cloud from a text input.

A word cloud is a visual representation for text data, typically used to depict keyword metadata (tags) on websites, or to visualize free form text. Tags are usually single words, and the importance of each tag is shown with font size or color. This format is useful for quickly perceiving the most prominent terms and for locating a term alphabetically to determine its relative prominence.

You can also use this library outside of Apps Script: This Word Cloud Creator is available as a REST API and a Web Application.
REST API: send an HTTP post request to the url above, with the text you want and you will get the HTML code of the corresponding word cloud in return.


  1. In the script editor, click on Resources > Manage librairies

  2. A popup box opens. Insert the following project key in the textbox: MMcAIHRDThfYEM5_Jj8ZH1uVJ5jnXUK_T and click on the Select button next to it.

  3. Click on the box listing the different versions of the library. Select the latest version available.

  4. Click OK. You can now use this library.


The code below read the first 100 conversations in your Gmail Inbox, create a word cloud out of them and send it to you by email.

function seeTopWordsInMyGmailInbox() {
  var threads = GmailApp.getInboxThreads(0, 100);
  var messagesforAllThreads = GmailApp.getMessagesForThreads(threads);
  var input = '';
  for(i in messagesforAllThreads) {
    for(j in messagesforAllThreads[i]) {
      input+=  messagesforAllThreads[i][j].getBody();
  var wordCloud = WordCloudLib.getWordCloud(input);
  var me = Session.getActiveUser().getEmail();
  MailApp.sendEmail(me, 'Word Cloud of my Gmail Inbox', '', {htmlBody: wordCloud});