How to Perform Profanity and Obscene Language Analysis and Detection on Text with JavaScript

Cloudmersive
2 min readMay 20, 2022

Hey — no cursing on my website!

Are you getting tired of asking people to keep it clean? We hear you. When you include our Profanity and Obscene Language Detection API in your app, you won’t have to. This API analyzes (English) natural language text inputs and provides a score indicating the degree to which the text in question is profane or obscene. That score will range from 0.0 to 1.0, with lower numbers indicating little profanity was detected, and higher numbers indicating a lot of profanity was detected.

To structure your API call in JavaScript, follow instructions to include ready-to-run code snippets below.

Let’s install the jQuery library first:

bower install jquery

Then let’s include the code for our API call:

var settings = {
"url": "https://api.cloudmersive.com/nlp-v2/analytics/profanity",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/x-www-form-urlencoded",
"Apikey": "YOUR-API-KEY-HERE"
},
"data": {
"TextToAnalyze": "<string>"
}
};
$.ajax(settings).done(function (response) {
console.log(response);
});

You’ll need to include your Cloudmersive API key (attainable by creating a free account on our website — Home — Cloudmersive APIs) and configure your text input where indicated in the documentation. Once you do that, you’re all good to go.

--

--

Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.