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

12PHP

Since Jul 28Pushed 9mo 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 1mo ago

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

Maintenance43

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity13

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://www.gravatar.com/avatar/737309009556148504fdfa600e707715aff45c32cdc500627b79ecf9c37afce4?d=identicon)[gacbaluyot](/maintainers/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

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

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