PHPackages                             devtrope/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. [Search &amp; Filtering](/categories/search)
4. /
5. devtrope/profanity-filter

ActiveLibrary[Search &amp; Filtering](/categories/search)

devtrope/profanity-filter
=========================

A profanity filter for PHP

v0.0.4(9mo ago)016↓100%PHPPHP &gt;=8.1

Since Aug 7Pushed 9mo agoCompare

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

READMEChangelogDependencies (2)Versions (5)Used By (0)

ProfanityFilter
===============

[](#profanityfilter)

A lightweight and customizable PHP package for detecting and censoring profanity in text.
Includes multiple sensitivity levels, support for custom word lists, and is PSR-12 and PHPStan compatible.

[![Latest Stable Version](https://camo.githubusercontent.com/877e06ec43be8d3b0fb86a82a74af496b1af123ab006c9a16c5326aecb092148/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64657674726f70652f70726f66616e6974792d66696c7465722e737667)](https://packagist.org/packages/devtrope/profanity-filter)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](LICENSE)[![Static Analysis: PHPStan](https://camo.githubusercontent.com/6cc8ce93bfedc6a3c8a403a08172567e0f91343907f1dc549b900f11a1004dac/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f737461746963253230616e616c797369732d7068707374616e2d626c7565)](https://phpstan.org)[![Code Style: PSR-12](https://camo.githubusercontent.com/a7ee356ff7f73b55f4fc2118179b81fb834bc04af9ae7564f76de6baf3932ca9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f64652532307374796c652d5053522d2d31322d6c69676874677265792e737667)](https://www.php-fig.org/psr/psr-12/)[![Downloads](https://camo.githubusercontent.com/cc76cb0514e2dacd061d91a7c961226825213a0dde175f58c7b6a42b4074f24e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64657674726f70652f70726f66616e6974792d66696c7465722e737667)](https://packagist.org/packages/devtrope/profanity-filter)[![PHP Version](https://camo.githubusercontent.com/df3dece126a9a10cb2f7fe1181d24358fbe16ecfb48edb146748364e4c6de341/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f64657674726f70652f70726f66616e6974792d66696c7465722e737667)](https://packagist.org/packages/devtrope/profanity-filter)

---

Features
--------

[](#features)

- Detects offensive words in strings
- Supports multiple filtering levels: `low`, `medium`, `high`
- Supports multiple languages (en, fr)
- Custom blacklist support via JSON file
- Add or remove words dynamically at runtime
- Fully typed and ready for static analysis
- Easy integration with existing projects

---

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

[](#installation)

Install via Composer:

```
composer require devtrope/profanity-filter
```

---

Usage
-----

[](#usage)

### Basic usage

[](#basic-usage)

```
use ProfanityFilter\ProfanityFilter;
use ProfanityFilter\ProfanityLevel;

$filter = new ProfanityFilter();
$text = "You little piece of shit!";
echo $filter->clean($text); // You little piece of ****!
```

### With a specific language

[](#with-a-specific-language)

```
$filter = new ProfanityFilter(ProfanityLevel::HIGH, 'fr');
```

### With a custom blacklist

[](#with-a-custom-blacklist)

```
$filter = new ProfanityFilter(
    ProfanityLevel::HIGH,
    'fr',
    __DIR__ . '/my-custom-blacklist.json'
);
```

```
{
    "low": ["wordlow"],
    "medium": ["wordmedium"],
    "high": ["wordhigh"]
}
```

### Add or remove words at runtime

[](#add-or-remove-words-at-runtime)

```
$filter->addWord('uglyword');
$filter->removeWord('otheruglyword');
```

### Check if a text contains profanity

[](#check-if-a-text-contains-profanity)

```
if ($filter->containsProfanity($text)) {
    echo "Inappropriate content detected!";
}
```

---

Language support
----------------

[](#language-support)

Currently supported locales:

- `en` - English
- `fr` - Français

---

Profanity levels
----------------

[](#profanity-levels)

Each level includes all words from the previous level:

LevelDescriptionLOWMild profanityMEDIUMDefault, balancedHIGHAgressive filtering---

License
-------

[](#license)

MIT License - see [LICENSE](LICENSE.md) for details.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance62

Regular maintenance activity

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 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 ~0 days

Total

4

Last Release

275d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e51cb34a58e8765ffa70ed79cb4ae3e86a24f635819de947a749d78ffb927341?d=identicon)[qschifferle](/maintainers/qschifferle)

---

Top Contributors

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

---

Tags

filteringphp-libraryprofanity-detectionprofanity-filterphpfilterprofanity

###  Code Quality

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

PHPackages © 2026

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