Skip to content

Languages & Dictionaries

Choose bundled English or build a detector from explicit language packs.

Updated View as Markdown

Profanity Kit separates its detector engine from language dictionaries. Choose the entry point based on who should control the language data.

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"); // => false

Its 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"); // => false

Its 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.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close