Build an Online Sentiment Analysis Tool with ml5.js and React in 10 Minutes

Joel Masters
2 min readNov 19, 2020
Photo by Hybrid on Unsplash

Sentiment analysis is one of the popular applications of machine learning. We’re going to use the ml5.js library (which is a wrapper around tensorflow.js)along with React to create an online sentiment analysis tool.

First, we’ll import the ml5.js library. Then, we’ll add some UI elements to interact with ml5.js. Then, we’ll push to GitHub. Finally, we’ll host it on Netlify.

Let’s get started!

Step 1 of 5: Create A New React Project Using Create-React-App

In your terminal, type:

npx create-react-app my-sentiment-app
cd my-sentiment-app

Step 2 of 5: Import ml5.js

In the index.html file, import ml5.js:

<script src=""></script>

into the <head> section, and remove the extra boilerplate code:

For more information on getting started with ml5.js, visit

Step 3 of 5: Add the UI Elements and Logic

In App.js create three html elements: a textArea element, a button, and an output element. Additionally, we’ll load the model and run the analyzer when the calculate button is clicked.

Step 4 of 5: Push to GitHub

Create a new repository on GitHub and push files up. (For a more detailed explanation of how to create a new repository and push files, see

Step 5 of 5: Host on Netlify

Login to your Netlify account (or create a new one if necessary) and create a new site from git. Select your GitHub repository and click deploy site. (For a more detailed explanation of how to host on Netlify, see

Sentiment Analyzer App

To see a live implementation, visit:

Thanks for reading!