PHPackages                             waad/laravel-profanity-filter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. waad/laravel-profanity-filter

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

waad/laravel-profanity-filter
=============================

Laravel Profanity Filter - Powerful PHP package for detecting, filtering, and masking profanity in multiple languages. Supports leet speak, custom word lists, case sensitivity, and seamless Laravel integration.

v1.2.1(1mo ago)202.9k—9.3%1MITPHPPHP ^8.0

Since Jun 23Pushed 1mo agoCompare

[ Source](https://github.com/waadmawlood/laravel-profanity-filter)[ Packagist](https://packagist.org/packages/waad/laravel-profanity-filter)[ Docs](https://github.com/waad/laravel-profanity-filter)[ RSS](/packages/waad-laravel-profanity-filter/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (7)Versions (5)Used By (0)

[![Laravel Profanity Filter](banner.jpg)](banner.jpg)

Laravel Profanity Filter
========================

[](#laravel-profanity-filter)

A powerful, flexible, and easy-to-use PHP Laravel package for detecting, filtering, and masking profanity in multiple languages. Includes advanced features such as leet speak detection, custom word lists, language auto-detection, and real-time configuration.

---

🚀 Features
----------

[](#-features)

- **Multi-language support:** Detects profanity in English, French, Arabic, and more
- **Customizable masking:** Replace profane words with your own masking character(s)
- **Leet speak &amp; substitutions:** Detects obfuscated words (e.g., "f@ck", "sh!t", "d4mn")
- **Custom word lists:** Add or override profane words per language
- **Case sensitivity:** Toggle case-sensitive or insensitive detection
- **Separator handling:** Detects words with separators (e.g., d-a-m-n, s\_h\_i\_t)
- **Laravel integration:** Seamless usage via Facade, Service Provider, and config
- **Real-time configuration:** Update settings and word lists at runtime
- **Extensible:** Easily add new languages, separators, or substitutions
- **Import custom words from files:** Load additional profanity words from `.txt` or `.json` files per language

---

🛠 Requirements
--------------

[](#-requirements)

- `PHP 8.0+`
- `Laravel 8+`

Installation
------------

[](#installation)

### Via Composer

[](#via-composer)

```
composer require waad/laravel-profanity-filter
```

Publish the configuration file:

```
php artisan vendor:publish --tag="profanity-filter"
```

Publish the words (`Optional`) ⚠️:

```
php artisan vendor:publish --tag="profanity-words"
```

### Configuration

[](#configuration)

You can configure the package by editing the `profanity-filter.php` file in the `config` directory.

Usage
-----

[](#usage)

### Using `hasProfanity` method

[](#using-hasprofanity-method)

```
use Waad\ProfanityFilter\Facades\ProfanityFilter;

$text = "This is a test string with some profanity like fuck and shit.";
$hasProfanity = ProfanityFilter::hasProfanity($text);

echo $hasProfanity; // true
```

### Using `filter` method

[](#using-filter-method)

```
use Waad\ProfanityFilter\Facades\ProfanityFilter;

$text = "This is a test string with some profanity like fuck and shit.";
$filteredText = ProfanityFilter::filter($text);

echo $filteredText; // This is a test string with some profanity like **** and ****.
```

### Using `getProfanityWords` method

[](#using-getprofanitywords-method)

```
use Waad\ProfanityFilter\Facades\ProfanityFilter;

$text = "This is a test string with some profanity like fuck and shit.";
$profanityWords = ProfanityFilter::getProfanityWords($text);

print_r($profanityWords);
// Output: Array ( [0] => fuck [1] => shit )
```

### Using `setLanguage` method

[](#using-setlanguage-method)

```
use Waad\ProfanityFilter\Facades\ProfanityFilter;

ProfanityFilter::setLanguage('en'); // default is null (auto detect language)

$text = "This is a test string with some profanity like fuck and shit.";
$filteredText = ProfanityFilter::filter($text);

echo $filteredText; // This is a test string with some profanity like **** and ****.
```

### Using `setCaseSensitive` method

[](#using-setcasesensitive-method)

```
use Waad\ProfanityFilter\Facades\ProfanityFilter;

ProfanityFilter::setCaseSensitive(true); // default is false

$text = "This is a test string with some profanity like fuck and Fuck.";
$filteredText = ProfanityFilter::filter($text);

echo $filteredText; // This is a test string with some profanity like **** and Fuck.
```

### Using `setDetectLeetSpeak` method

[](#using-setdetectleetspeak-method)

```
use Waad\ProfanityFilter\Facades\ProfanityFilter;

ProfanityFilter::setDetectLeetSpeak(true); // default is true

$text = "This is a test string with some profanity like f@ck and sh!t.";
$filteredText = ProfanityFilter::filter($text);

echo $filteredText; // This is a test string with some profanity like **** and ****.
```

### Using `setConfig` method

[](#using-setconfig-method)

You can update the package configuration in real time using Laravel's `config()` helper, or by editing the `profanity-filter.php` file in the `config` directory.

```
use Waad\ProfanityFilter\Facades\ProfanityFilter;

config(['profanity-filter.custom_words.en' => ['custom']]);
ProfanityFilter::setConfig(config('profanity-filter'));

$text = "This is a test string with some profanity like fuck and shit.";
$filteredText = ProfanityFilter::filter($text);

echo $filteredText; // This is a test string with some profanity like **** and ****.
```

### Using `importWordsFromFile` method

[](#using-importwordsfromfile-method)

You can import additional profanity words from a file (JSON or TXT) at runtime using the `importWordsFromFile` method. This is useful for dynamically extending the list of profane words without modifying the config file.

```
use Waad\ProfanityFilter\Facades\ProfanityFilter;

// Import words from a TXT file
ProfanityFilter::importWordsFromFile(storage_path('app/profanity-words.txt'), 'en');

// Import words from a JSON file
ProfanityFilter::importWordsFromFile(storage_path('app/profanity-words.json'), 'en');

$text = "This is foo and bar and alpha.";
$filteredText = ProfanityFilter::filter($text);

echo $filteredText; // This is *** and *** and *****.
```

### Using `addWords` method

[](#using-addwords-method)

You can add custom profanity words in real time using the `addWords` method. This is useful for dynamically adding words without modifying the config file.

```
use Waad\ProfanityFilter\Facades\ProfanityFilter;

// Add a single word
ProfanityFilter::addWords('badword', 'en');

// Add multiple words at once
ProfanityFilter::addWords(['testword1', 'testword2'], 'en');
ProfanityFilter::addWords(collect(['testword3', 'testword4']), 'en');

$text = "This is badword and testword1 and testword3 and testword4.";
$filteredText = ProfanityFilter::filter($text);

echo $filteredText; // This is ******* and ********* and ********* and *********.
```

### Using `removeWords` method

[](#using-removewords-method)

You can remove profanity words from the filter in real time using the `removeWords` method.

```
use Waad\ProfanityFilter\Facades\ProfanityFilter;

// Remove a single word
ProfanityFilter::removeWords('damn', 'en');

// Remove multiple words at once
ProfanityFilter::removeWords(['shit', 'hell'], 'en');

$text = "This is damn and shit.";
$hasProfanity = ProfanityFilter::hasProfanity($text);

echo $hasProfanity; // false
```

### Using `clearWords` method

[](#using-clearwords-method)

You can clear all profanity words for a specific language in real time using the `clearWords` method.

```
use Waad\ProfanityFilter\Facades\ProfanityFilter;

// Clear all words for English
ProfanityFilter::clearWords('en');

$text = "This is damn and shit.";
$hasProfanity = ProfanityFilter::hasProfanity($text);

echo $hasProfanity; // false
```

### Using `getWords` method

[](#using-getwords-method)

You can retrieve all profanity words for a specific language using the `getWords` method.

```
use Waad\ProfanityFilter\Facades\ProfanityFilter;

$words = ProfanityFilter::getWords('en');

print_r($words);
// Output: Array ( [0] => damn [1] => shit [2] => ... )
```

### Example All Methods

[](#example-all-methods)

```
use Waad\ProfanityFilter\Facades\ProfanityFilter;

$text = "This is a test string with some profanity like f@ck and sh!t.";
ProfanityFilter::setLanguage('en')
    ->setDetectLeetSpeak(true)
    ->setCaseSensitive(false)
    ->addWords('customword', 'en');

ProfanityFilter::hasProfanity($text); // true
ProfanityFilter::filter($text); // This is a test string with some profanity like *@** and **!*.

// Chaining word management methods
ProfanityFilter::addWords(['word1', 'word2'], 'en')
    ->removeWords('word1', 'en')
    ->clearWords('fr');

$words = ProfanityFilter::getWords('en');
```

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a pull request.

Testing
-------

[](#testing)

To run the tests, you can use the following command:

```
composer test
```

To Do
-----

[](#to-do)

- Add support for multiple languages
- Add support for custom words
- Add support for leet speak
- Add support for case sensitivity
- Add support for separators
- Add support for custom replacements
- Add support for custom separators
- Add support for custom substitutions
- Add support for custom word lists
- Add support for custom word lists per language
- Add support for custom word from files (json, txt)
- Add support for custom word lists in real time

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance89

Actively maintained with recent releases

Popularity32

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~89 days

Total

4

Last Release

54d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/44348636?v=4)[Waad Mawlood](/maintainers/waadmawlood)[@waadmawlood](https://github.com/waadmawlood)

---

Top Contributors

[![waadmawlood](https://avatars.githubusercontent.com/u/44348636?v=4)](https://github.com/waadmawlood "waadmawlood (6 commits)")

---

Tags

laravellaravel-frameworkprofanityprofanity-detectionprofanity-filterphplaravellaravel-packageprofanityprofanity detectioncontent moderationProfanity FilterMaskingbad wordsswear wordstext filterlanguage filterleet speakcustom words

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/waad-laravel-profanity-filter/health.svg)

```
[![Health](https://phpackages.com/badges/waad-laravel-profanity-filter/health.svg)](https://phpackages.com/packages/waad-laravel-profanity-filter)
```

###  Alternatives

[monicahq/laravel-cloudflare

Add Cloudflare ip addresses to trusted proxies for Laravel.

3372.7M4](/packages/monicahq-laravel-cloudflare)[kra8/laravel-snowflake

Snowflake for Laravel and Lumen.

188402.3k6](/packages/kra8-laravel-snowflake)[imanghafoori/laravel-nullable

A package to help you write expressive defensive code in a functional manner

151423.7k6](/packages/imanghafoori-laravel-nullable)[bezhansalleh/filament-google-analytics

Google Analytics integration for FilamentPHP

205144.8k5](/packages/bezhansalleh-filament-google-analytics)[laragear/preload

Effortlessly make a Preload script for your Laravel application.

119363.5k](/packages/laragear-preload)[erag/laravel-pwa

A simple and easy-to-use PWA (Progressive Web App) package for Laravel applications.

16083.3k](/packages/erag-laravel-pwa)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
