skillfed

better-profanity

Blazingly fast cleaning swear words (and their leetspeak) in strings

better-profanity v0.7.0 1.7M downloads/30d#3,659 on PyPI232
Permissive license DORMANT released

What it is and what it does

better_profanity is a string-based profanity filter that replaces swear words and their common leetspeak variants (like p0rn, h4NDjob) with asterisks or a custom character. It works by loading a wordlist and generating all common character substitutions, then checking for matches using direct string comparison rather than regex. The package has no runtime dependencies and installs as a pure Python wheel.

The library handles word boundaries loosely—it censors profanity separated by spaces, underscores, commas, and periods, but preserves @, $, *, ", and ' as non-separators. You can load the built-in wordlist, supply a custom list, load from a file, add words dynamically, or whitelist specific terms. It includes a `contains_profanity()` check to detect without censoring. The package is dormant (last updated 2020-11-02).

Use it for:

  • Filter user-generated content in forums, chat systems, or comment sections before display.
  • Detect profanity in moderation workflows to flag posts for human review.
  • Clean text datasets for machine learning training to remove offensive language.
  • Censor profanity in real-time messaging or live-chat applications.
  • Build custom content policies by loading domain-specific wordlists and whitelists.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Detects and censors profanity in text, including leetspeak variations like p0rn and h4NDjob, using fast string comparison instead of regex.

Yes, if you need a lightweight, zero-dependency profanity filter. Low install friction and permissive license make integration straightforward. However, maintenance is dormant since 2020-11-02, so the wordlist and codebase are not actively updated. The package has documented limitations: it can be bypassed by adding extra characters, and compound words with non-space separators are not filtered. Use for basic content moderation or as a first-pass filter.

Install

better-profanity on PyPI

pip

pip install better-profanity

uv

uv add better-profanity

poetry

poetry add better-profanity

Installing better-profanity

Before you install

Low friction: pure Python wheel with no runtime dependencies. Maintenance is dormant—last release was 2020-11-02, over 2111 days ago—so expect no active bug fixes or updates.

License in practice

MIT license permits commercial and private use with minimal restrictions; you must include a copy of the license in distributions.

Quickstart

from better_profanity import profanity

profanity.load_censor_words()
text = "You p1ec3 of sHit."
censored = profanity.censor(text)
print(censored)  # You **** of ****.

Requires Python 3.* support as declared in package metadata.

Verify before relying

  • Whether the default wordlist reflects current profanity coverage or remains static from 2020.
  • Performance characteristics on very large texts or high-frequency filtering workloads.
  • Unicode support limitations beyond stated exclusion of Chinese; which other languages are unsupported.

Package facts

License not declared (permissive)
Python support supports the current Python release (==3.*)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance dormant — 2,111 days since the last release
Last repo commit
First released
Downloads 1,678,810/month — #3,659 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: better_profanity-0.7.0-py3-none-any.whl

License :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3

Tags

profanity filtercensor swear wordstext content moderationleetspeak profanity detectionbad word filtercontent filtering libraryprofanity detection
content-moderationtext-filtering

More Text Processing packages