PHPackages                             sworup/profanityfilter - 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. sworup/profanityfilter

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

sworup/profanityfilter
======================

Profanity filter package would help you censor some of the bad words users put in your posts and/or comments.

1.0.1(5y ago)94.4k↓50%2[1 issues](https://github.com/sworup/ProfanityFilter/issues)MITPHPPHP &gt;=5.3.0

Since Jan 25Pushed 5y ago3 watchersCompare

[ Source](https://github.com/sworup/ProfanityFilter)[ Packagist](https://packagist.org/packages/sworup/profanityfilter)[ Docs](https://github.com/Sworup/ProfanityFilter)[ RSS](/packages/sworup-profanityfilter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (3)Used By (0)

Profanity Filter
================

[](#profanity-filter)

[![Latest Version on Packagist](https://camo.githubusercontent.com/1ce6afd124e58989b6ca3b78e3a2c4a04c2f8ebea61a39fcd2f4fe5480c4482f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73776f7275702f70726f66616e69747966696c7465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sworup/profanityfilter)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/4889058b492a9a44bdb1b25a3369471c16afe8d63f5e544b5749cbbfc88f6438/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f73776f7275702f50726f66616e69747946696c7465722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/sworup/ProfanityFilter)[![Quality Score](https://camo.githubusercontent.com/7b9408508d5b67ab8cd7f5b31c6d26026808f9cb18c634055be1df07c46f2075/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f73776f7275702f50726f66616e69747946696c7465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/sworup/ProfanityFilter)[![Total Downloads](https://camo.githubusercontent.com/3ec8818e9c9a50e4c5a0a9adb4fc2f64c92b0b64adcd8dfdb73bff80a93238f4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73776f7275702f70726f66616e69747966696c7465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sworup/profanityfilter)

Profanity Filter takes strings as input and removes any bad curse words that the string might have. It checks the strings for specific blacklist which must match as a separate word to be considered as a curse word. If a curse word is found, then it will replace the curse word with a censor character the user chooses (default is \*).

This package is intended to used with Laravel. Tested and working with laravel 5.4.

If you want to override the Package's config file, just copy it and rename it to `config/profanity-filter.php`, and update as per your needs.

This code is based on [Fastwebmedia/Profanity-Filter](https://github.com/fastwebmedia/Profanity-Filter). A major part of it is taken from there and I added the things that I thought it required.

Install
-------

[](#install)

Via Composer

```
$ composer require sworup/profanityfilter
```

\###Laravel Add `'Sworup\ProfanityFilter\ProfanityServiceProvider'` to your providers array.

If you wish to use the Facade then add `'Profanity'         => 'Sworup\ProfanityFilter\Profanity'`

The package will automatically use the config file containing the list of banned words.

Usage
-----

[](#usage)

```
$swear_word = ['dog'];
$blacklist  = ['puppy'];
$replace    = ['a' => '(a|a\.|a\-|4|@|Á|á|À|Â|à|Â|â|Ä|ä|Ã|ã|Å|å|α|Δ|Λ|λ)'];

$profanity_filter = new sworup\ProfanityFilter($swear_words, $blacklist, $replace);
echo $profanity_filter->clean('Dog, puppy badpuppy baddog!', '$');
```

The above code would return:

```
array(
    'old_string' => 'Dog, puppy badpuppy baddog!',
    'new_string' => '$$$, $$$$$ badpuppy bad$$$!',
    'clean'      => false
);
```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information about what has changed recently.

Testing
-------

[](#testing)

```
$ phpspec run
```

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Sworup Shakya](https://github.com/sworup)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% 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 ~1475 days

Total

2

Last Release

1925d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8c3cb26f2b011882389b31077b0dabe0c5bd9f44a5e11f65a2a4b1fdce1933bc?d=identicon)[sworup](/maintainers/sworup)

---

Top Contributors

[![sworup](https://avatars.githubusercontent.com/u/683452?v=4)](https://github.com/sworup "sworup (4 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (2 commits)")

---

Tags

laravelpackageprofanity-filterlaravelcensorProfanity Filterswear wordcurse wordsremove profanity

### Embed Badge

![Health badge](/badges/sworup-profanityfilter/health.svg)

```
[![Health](https://phpackages.com/badges/sworup-profanityfilter/health.svg)](https://phpackages.com/packages/sworup-profanityfilter)
```

###  Alternatives

[askedio/laravel5-profanity-filter

A Vendor Package Example

52354.1k](/packages/askedio-laravel5-profanity-filter)[laravel-validation-rules/us-state

Validate US States and Canada Provinces

16172.7k](/packages/laravel-validation-rules-us-state)[pacerit/laravel-polish-validation-rules

Simple Polish Validation rules for Laravel and Lumen framework

1449.9k](/packages/pacerit-laravel-polish-validation-rules)[laravel-validation-rules/ip

Validate if an ip address is public or private.

1629.7k](/packages/laravel-validation-rules-ip)[janvince/smallcontactform

Simple but flexible multi language contact form builder with custom fields, validation and passive antispam

307.4k](/packages/janvince-smallcontactform)[basillangevin/laravel-data-json-schemas

Transforms Spatie Data objects into JSON Schemas with built-in validation

1312.2k1](/packages/basillangevin-laravel-data-json-schemas)

PHPackages © 2026

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