PHPackages                             gacbaluyot/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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. gacbaluyot/profanity-filter

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

gacbaluyot/profanity-filter
===========================

A lightweight, multilingual profanity detection and censorship library written in native PHP

16PHP

Since Jul 28Pushed 11mo agoCompare

[ Source](https://github.com/gacbaluyot/profanity-filter)[ Packagist](https://packagist.org/packages/gacbaluyot/profanity-filter)[ RSS](/packages/gacbaluyot-profanity-filter/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

PHP Profanity Filter
====================

[](#php-profanity-filter)

A lightweight, multilingual profanity detection and censorship library written in native PHP.

Supports dynamic language loading, custom word lists, and Unicode-safe pattern matching.

---

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

[](#-features)

- Detects profanity in text using prebuilt JSON wordlists
- Supports multiple languages:
    - English (`en`)
    - Russian (`ru`)
    - Italian (`it`)
    - Indonesian (`id`)
    - Chinese (`zh`)
    - Japanese (`ja`)
- Add or override custom bad words
- Merge multiple language filters or use all at once
- Extract, censor, or save profane words
- PHPUnit test suite included

---

📦 Installation
--------------

[](#-installation)

Clone the repo and include via Composer:

```
composer install
```

Make sure your autoloader can resolve `ProfanityFilter\ProfanityFilter` from `/src`.

---

📂 Usage
-------

[](#-usage)

### Basic Detection

[](#basic-detection)

```
use ProfanityFilter\ProfanityFilter;

$filter = new ProfanityFilter('en');

$text = "You idiot!";

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

### Censor Words

[](#censor-words)

```
$censored = $filter->censor("You dumb bastard!");
echo $censored; // You **** *******!
```

### Get Detected Words

[](#get-detected-words)

```
$words = $filter->getProfaneWords("That was stupid and shitty.");
print_r($words); // ['stupid', 'shitty']
```

### Use Multiple Languages

[](#use-multiple-languages)

```
$filter->setLanguages(['en', 'ru']);
```

### Use All Languages

[](#use-all-languages)

```
$filter->useAllLanguages();
```

### Add Custom Words

[](#add-custom-words)

```
$filter->addCustomWords(['meanie', 'dummy']);
```

### Save &amp; Load Custom Word List

[](#save--load-custom-word-list)

```
$filter->saveUpdatedWordList(__DIR__ . '/my-words.json');
$filter->setWordListFromFile(__DIR__ . '/my-words.json');
```

---

🧪 Running Tests
---------------

[](#-running-tests)

```
vendor/bin/phpunit tests/
```

Make sure you’ve run:

```
composer dump-autoload
```

to register autoload-dev.

---

📁 Language Wordlist Files
-------------------------

[](#-language-wordlist-files)

Each language is stored in a separate JSON file in `src/data/`, e.g.:

```
src/data/en.json
src/data/ru.json
src/data/zh.json

```

You can extend these manually or via the library methods.

---

📝 License
---------

[](#-license)

MIT Licensed. Use at your own discretion — offensive content warning applies.

---

🙌 Contributions Welcome!
------------------------

[](#-contributions-welcome)

Feel free to fork, submit PRs, or suggest new languages and improvements!

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity14

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/71457640?v=4)[Gerard Baluyot](/maintainers/gacbaluyot)[@gacbaluyot](https://github.com/gacbaluyot)

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[marcosh/php-validation-dsl

A DSL for validating data in a functional fashion

483.9k](/packages/marcosh-php-validation-dsl)

PHPackages © 2026

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