profanity-kit
v0.2.0
Published
A lightweight, multilingual profanity detector for JavaScript and TypeScript.
Maintainers
Readme
Profanity Kit is a language-pack-based profanity detection toolkit built for multilingual applications. Select and combine only the languages you need, or provide custom packs for specific communities. English and Indonesian packs are available today, with more built-in languages coming soon!
It provides predictable, synchronous word filtering without a moderation service or an opaque machine-learning model. It is a deterministic profanity detection toolkit, not a contextual moderation or toxicity classifier.
Why Profanity Kit?
- Unicode-aware, whole-word matching
- Built-in English and Indonesian packs, with more languages planned
- Explicit, bundle-friendly multilingual configuration
- Detailed match metadata with source offsets
- Immutable detector configuration
- Synchronous and runtime agnostic
- Zero runtime dependencies
Available languages
| Language | Import |
| ---------- | ---------------------------- |
| English | profanity-kit/languages/en |
| Indonesian | profanity-kit/languages/id |
Language packs can be used independently or combined in one detector. Custom packs support additional languages and communities.
Installation
| Package manager | Command |
| --------------- | --------------------------- |
| npm | npm install profanity-kit |
| pnpm | pnpm add profanity-kit |
| Yarn | yarn add profanity-kit |
| Bun | bun add profanity-kit |
Quick start
The root entry point includes the English language pack:
import { createDetector } from "profanity-kit";
const detector = createDetector();
detector.check("This contains shit"); // true
detector.filter("Hide the shit"); // "Hide the ****"Use the dictionary-free core to combine the built-in English and Indonesian language packs:
import { createDetector } from "profanity-kit/core";
import { english } from "profanity-kit/languages/en";
import { indonesian } from "profanity-kit/languages/id";
const detector = createDetector({ languages: [english, indonesian] });
detector.check("This contains shit"); // true
detector.check("Dasar goblok"); // trueLoad either pack independently when only one language is needed, or supply a custom language pack for another language or community.
Learn more
Compatibility
Profanity Kit supports Node.js 22.13.0 or newer and modern browsers under the Baseline Widely Available policy. It ships as ESM with TypeScript declarations.
Contributing
Contributions are welcome. Read the contribution guide before opening an issue or pull request.
