better-profanity
Blazingly fast cleaning swear words (and their leetspeak) in strings
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-profanityuv
uv add better-profanitypoetry
poetry add better-profanityInstalling 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
Tags
More Text Processing packages
A drop-in replacement for Python's standard…
permissive · top 100 on PyPI
pyparsingpyparsing provides a library for building text…
permissive · top 1,000 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
RapidFuzzRapidFuzz provides fast fuzzy string matching…
permissive · top 1,000 on PyPI
tinycss2tinycss2 parses CSS strings into token and…
permissive · top 1,000 on PyPI
llama-parseLlamaParse parses complex documents (PDFs,…
permissive · top 1,000 on PyPI
alt-profanity-checkDetects offensive or profane language in text…
permissive · top 15,000 on PyPI
codespellCodespell finds and fixes common misspellings…
copyleft · top 5,000 on PyPI
pyspellcheckerDetects misspelled words and suggests…
permissive · top 5,000 on PyPI
confusablesDetects and matches words that appear identical…
permissive · top 15,000 on PyPI
wonderwordsGenerates random English words and sentences…
permissive · top 15,000 on PyPI
stop-wordsProvides curated stop-word lists for multiple…
permissive · top 15,000 on PyPI
sanitize-filenameRemoves or replaces problematic characters from…
permissive · top 15,000 on PyPI
textsearchFind and replace multiple strings in text with…
permissive · top 15,000 on PyPI
confusable-homoglyphsDetects Unicode homoglyphs and mixed-script…
permissive · top 5,000 on PyPI
xkcdpassGenerates strong, memorable passphrases by…
permissive · top 15,000 on PyPI