JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 12221
  • Score
    100M100P100Q166088F
  • License ISC

Glin-Profanity is a lightweight and efficient npm package designed to detect and filter profane language in text inputs across multiple languages. Whether youโ€™re building a chat application, a comment section, or any platform where user-generated content is involved, Glin-Profanity helps you maintain a clean and respectful environment.

Package Exports

  • glin-profanity

Readme

Glin Profanity

GLIN PROFANITY

A multilingual profanity detection and filtering engine for modern applications โ€” by GLINCKER

Try Live Demo

NPM Version MIT License CI Status Weekly Downloads Open Issues Open PRs Last Commit GitHub Stars GitHub Forks Contributors Table Of Contents


A multilingual profanity detection and filtering engine for modern applications โ€” by GLINCKER

Glin Profanity Preview


โœจ Overview

Glin-Profanity is a high-performance JavaScript/TypeScript library built to detect, filter, and sanitize profane or harmful language in user-generated content. With support for over 20+ languages, configurable severity levels, obfuscation detection, and framework-agnostic design, it's perfect for developers who care about building safe, inclusive platforms.

Whether you're moderating chat messages, community forums, or content input forms, Glin-Profanity empowers you to:

  • ๐Ÿงผ Filter text with real-time or batch processing
  • ๐Ÿ—ฃ๏ธ Detect offensive terms in 20+ human languages
  • ๐Ÿ’ฌ Catch obfuscated profanity like sh1t, f*ck, a$$hole
  • ๐ŸŽš๏ธ Adjust severity thresholds (Exact, Fuzzy, Merged)
  • ๐Ÿ” Replace bad words with symbols or emojis
  • ๐Ÿงฉ Works in any JavaScript environment - Node.js React Vue Angular TypeScript
  • ๐Ÿ›ก๏ธ Add custom word lists or ignore specific terms

๐Ÿš€ Key Features

Multi-Language Real-Time Obfuscation Framework Agnostic

๐Ÿ“š Table of Contents

Installation

npm yarn pnpm

To install Glin-Profanity, use npm:

npm install glin-profanity

OR

yarn add glin-profanity

OR

pnpm add glin-profanity

Supported Languages

Glin-Profanity includes comprehensive profanity dictionaries for 23 languages:

๐Ÿ‡ธ๐Ÿ‡ฆ Arabic โ€ข ๐Ÿ‡จ๐Ÿ‡ณ Chinese โ€ข ๐Ÿ‡จ๐Ÿ‡ฟ Czech โ€ข ๐Ÿ‡ฉ๐Ÿ‡ฐ Danish โ€ข ๐Ÿ‡ฌ๐Ÿ‡ง English โ€ข ๐ŸŒ Esperanto โ€ข ๐Ÿ‡ซ๐Ÿ‡ฎ Finnish โ€ข ๐Ÿ‡ซ๐Ÿ‡ท French โ€ข ๐Ÿ‡ฉ๐Ÿ‡ช German โ€ข ๐Ÿ‡ฎ๐Ÿ‡ณ Hindi โ€ข ๐Ÿ‡ญ๐Ÿ‡บ Hungarian โ€ข ๐Ÿ‡ฎ๐Ÿ‡น Italian โ€ข ๐Ÿ‡ฏ๐Ÿ‡ต Japanese โ€ข ๐Ÿ‡ฐ๐Ÿ‡ท Korean โ€ข ๐Ÿ‡ณ๐Ÿ‡ด Norwegian โ€ข ๐Ÿ‡ฎ๐Ÿ‡ท Persian โ€ข ๐Ÿ‡ต๐Ÿ‡ฑ Polish โ€ข ๐Ÿ‡ต๐Ÿ‡น Portuguese โ€ข ๐Ÿ‡ท๐Ÿ‡บ Russian โ€ข ๐Ÿ‡ช๐Ÿ‡ธ Spanish โ€ข ๐Ÿ‡ธ๐Ÿ‡ช Swedish โ€ข ๐Ÿ‡น๐Ÿ‡ญ Thai โ€ข ๐Ÿ‡น๐Ÿ‡ท Turkish

Note: The JavaScript and Python packages maintain cross-language parity, ensuring consistent profanity detection across both ecosystems.

Usage

Basic Usage

Glin-Profanity now provides framework-agnostic core functions alongside React-specific hooks:

๐ŸŸข Node.js / Vanilla JavaScript

const { checkProfanity } = require('glin-profanity');

const text = "This is some bad text with damn words";
const result = checkProfanity(text, {
  languages: ['english', 'spanish'],
  replaceWith: '***'
});

console.log(result.containsProfanity); // true
console.log(result.profaneWords);      // ['damn']
console.log(result.processedText);     // "This is some bad text with *** words"

๐Ÿ”ท TypeScript

import { checkProfanity, ProfanityCheckerConfig } from 'glin-profanity';

const config: ProfanityCheckerConfig = {
  languages: ['english', 'spanish'],
  severityLevels: true,
  autoReplace: true,
  replaceWith: '๐Ÿคฌ'
};

const result = checkProfanity("inappropriate text", config);

Framework Examples

Node.js React Vue.js Angular TypeScript

โš›๏ธ React

import React, { useState } from 'react';
import { useProfanityChecker, SeverityLevel } from 'glin-profanity';

const App = () => {
  const [text, setText] = useState('');
  
  const { result, checkText } = useProfanityChecker({
    languages: ['english', 'spanish'],
    severityLevels: true,
    autoReplace: true,
    replaceWith: '***',
    minSeverity: SeverityLevel.EXACT
  });

  return (
    <div>
      <input value={text} onChange={(e) => setText(e.target.value)} />
      <button onClick={() => checkText(text)}>Scan</button>
      
      {result && result.containsProfanity && (
        <p>Cleaned: {result.processedText}</p>
      )}
    </div>
  );
};

๐Ÿ’š Vue 3

<template>
  <div>
    <input v-model="text" @input="checkContent" />
    <p v-if="hasProfanity">{{ cleanedText }}</p>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import { checkProfanity } from 'glin-profanity';

const text = ref('');
const hasProfanity = ref(false);
const cleanedText = ref('');

const checkContent = () => {
  const result = checkProfanity(text.value, {
    languages: ['english'],
    autoReplace: true,
    replaceWith: '***'
  });
  
  hasProfanity.value = result.containsProfanity;
  cleanedText.value = result.autoReplaced;
};
</script>

๐Ÿ”ด Angular

import { Component } from '@angular/core';
import { checkProfanity, ProfanityCheckResult } from 'glin-profanity';

@Component({
  selector: 'app-comment',
  template: `
    <textarea [(ngModel)]="comment" (ngModelChange)="validateComment()"></textarea>
    <div *ngIf="profanityResult?.containsProfanity" class="error">
      Please remove inappropriate language
    </div>
  `
})
export class CommentComponent {
  comment = '';
  profanityResult: ProfanityCheckResult | null = null;

  validateComment() {
    this.profanityResult = checkProfanity(this.comment, {
      languages: ['english', 'spanish'],
      severityLevels: true
    });
  }
}

๐Ÿš‚ Express.js Middleware

const express = require('express');
const { checkProfanity } = require('glin-profanity');

const profanityMiddleware = (req, res, next) => {
  const result = checkProfanity(req.body.message || '', {
    languages: ['english'],
    autoReplace: true,
    replaceWith: '[censored]'
  });
  
  if (result.containsProfanity) {
    req.body.message = result.autoReplaced;
  }
  
  next();
};

app.post('/comment', profanityMiddleware, (req, res) => {
  // Message is now sanitized
  res.json({ message: req.body.message });
});

API

๐ŸŽฏ Core Functions

checkProfanity

Framework-agnostic function for profanity detection.

checkProfanity(text: string, config?: ProfanityCheckerConfig): ProfanityCheckResult

checkProfanityAsync

Async version of checkProfanity.

checkProfanityAsync(text: string, config?: ProfanityCheckerConfig): Promise<ProfanityCheckResult>

isWordProfane

Quick check if a single word is profane.

isWordProfane(word: string, config?: ProfanityCheckerConfig): boolean

๐Ÿ”ง Filter Class

Constructor

new Filter(config?: FilterConfig);

FilterConfig Options:

Option Type Description
languages Language[] Languages to include (e.g., ['english', 'spanish'])
allLanguages boolean If true, scan all available languages
caseSensitive boolean Match case exactly
wordBoundaries boolean Only match full words (turn off for substring matching)
customWords string[] Add your own words
replaceWith string Replace matched words with this string
severityLevels boolean Enable severity mapping (Exact, Fuzzy, Merged)
ignoreWords string[] Words to skip even if found
logProfanity boolean Log results via console
allowObfuscatedMatch boolean Enable fuzzy pattern matching like f*ck
fuzzyToleranceLevel number (0โ€“1) Adjust how tolerant fuzzy matching is
autoReplace boolean Whether to auto-replace flagged words
minSeverity SeverityLevel Minimum severity to include in final list
customActions (result) => void Custom logging/callback support

Methods

isProfane

Checks if a given text contains profanities.

isProfane(value: string): boolean;
  • value: The text to check.
  • Returns: boolean - true if the text contains profanities, false otherwise.
checkProfanity

Returns details about profanities found in the text.

checkProfanity(text: string): CheckProfanityResult;
  • text: The text to check.
  • Returns: CheckProfanityResult
    • containsProfanity: boolean - true if the text contains profanities, false otherwise.
    • profaneWords: string[] - An array of profane words found in the text.
    • processedText: string - The text with profane words replaced (if replaceWith is specified).
    • severityMap: { [word: string]: number } - A map of profane words to their severity levels (if severityLevels is specified).

โš›๏ธ useProfanityChecker Hook

A custom React hook for using the profanity checker.

Parameters

  • config: An optional configuration object (same as ProfanityCheckerConfig).

Return Value

  • result: The result of the profanity check.
  • checkText: A function to check a given text for profanities.
  • checkTextAsync: A function to check a given text for profanities asynchronously.
  • reset: A function to reset the result state.
  • isDirty: Boolean indicating if profanity was found.
  • isWordProfane: Function to check if a single word is profane.
const { result, checkText, checkTextAsync, reset, isDirty, isWordProfane } = useProfanityChecker(config);

Note

โš ๏ธ Glin-Profanity is a best-effort tool. Language evolves, and no filter is perfect. Always supplement with human moderation for high-risk platforms.

๐Ÿ›  Use Cases

  • ๐Ÿ” Chat moderation in messaging apps
  • ๐Ÿงผ Comment sanitization for blogs or forums
  • ๐Ÿ•น๏ธ Game lobbies & multiplayer chats
  • ๐Ÿค– AI content filters before processing input

License

This software is also available under the GLINCKER LLC proprietary license. The proprietary license allows for use, modification, and distribution of the software with certain restrictions and conditions as set forth by GLINCKER LLC.

You are free to use this software for reference and educational purposes. However, any commercial use, distribution, or modification outside the terms of the MIT License requires explicit permission from GLINCKER LLC.

By using the software in any form, you agree to adhere to the terms of both the MIT License and the GLINCKER LLC proprietary license, where applicable. If there is any conflict between the terms of the MIT License and the GLINCKER LLC proprietary license, the terms of the GLINCKER LLC proprietary license shall prevail.

MIT License

GLIN PROFANITY is MIT licensed.