Profanity Kit separates its detector engine from language dictionaries. Choose the entry point based on who should control the language data.
English and Indonesian are available as built-in language packs today. You can use either independently, combine both for multilingual input, or provide a custom pack for another language or community.
Each pack exposes its own data version. Packs version independently from the npm package and from one another; a version changes when that pack’s reviewed word data or curation policy changes.
Available languages
| Language | Import |
|---|---|
| English | profanity-kit/languages/en |
| Indonesian | profanity-kit/languages/id |
Choose an entry point
| Import | Dictionaries | Best for |
|---|---|---|
profanity-kit |
English included | English-only applications and shortest setup |
profanity-kit/core |
None; languages required |
Non-English, multilingual, custom-pack, and bundle-conscious apps |
Use bundled English
The root entry wraps core with the English pack. It does not accept a
languages option.
import { createDetector } from "profanity-kit";
const detector = createDetector();
detector.check("that is shit"); // => true
detector.check("dasar goblok"); // => falseIts type is ProfanityDetector<"en">.
Select one language
Import the dictionary-free core entry and a pack. languages must be a
non-empty array.
import { createDetector } from "profanity-kit/core";
import { indonesian } from "profanity-kit/languages/id";
const detector = createDetector({ languages: [indonesian] });
detector.check("dasar goblok"); // => true
detector.check("that is shit"); // => falseIts type is ProfanityDetector<"id">.
Combine languages
Pass multiple packs when input can contain multiple languages. Literal pack codes remain available in match result types.
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("shit"); // => true
detector.check("goblok"); // => true
detector.filter("shit dan goblok"); // => "**** dan ******"The inferred type is ProfanityDetector<"en" | "id">. When the same
normalized word occurs in several active packs, its match lists every pack.
Import only what you use
Core includes the engine but no words. Packs use separate module imports:
import { english } from "profanity-kit/languages/en";
import { indonesian } from "profanity-kit/languages/id";This gives bundlers a structural opportunity to exclude unused dictionaries. Choose the root entry for English convenience and core when dictionary selection or bundle composition should be explicit.
You can also supply a custom LanguagePack.
See Customization
for a complete example.
More languages
More built-in language packs are planned, but there is no committed language list or release schedule. Until a built-in pack is available, applications can provide a custom language pack through the same core API.
Native speakers and community reviewers are welcome to propose or contribute a new built-in pack. Open a GitHub issue before beginning substantial corpus work, then follow the contribution guide and dictionary review policy.