A fast, extensible and multilingual profanity detection engine for developers.
This is the real library, running in your browser inside a Web Worker. Type anything, pick a preset, switch languages and modes. Nothing leaves your machine.
–import { Terlik } from "terlik.js";
// one instance, warmed up at boot
const terlik = new Terlik();
terlik.containsProfanity("warmup");
io.on("connection", (socket) => {
socket.on("message", (text) => {
// <1ms per message after warmup
io.emit("message", terlik.clean(text));
});
});
Every trick people use gets undone before matching. The engine is language-agnostic — each language ships only data: a char map, a leet map, char classes and a dictionary.
In chat systems a false positive costs more than a miss — blocking “class” or “Amsterdam” erodes trust. terlik.js keeps a deliberately narrow dictionary and lets the engine do the expansion.
ESM + CJS, full TypeScript types, per-language sub-path imports when you want the smallest possible bundle.
import { Terlik } from "terlik.js";
const terlik = new Terlik(); // Turkish by default
terlik.containsProfanity("siktir git"); // true
terlik.clean("siktir git burdan"); // "****** git burdan"
terlik.containsProfanity("Amsterdam"); // false — whitelisted
const en = new Terlik({ language: "en" });
en.clean("what the phuck"); // "what the *****"
// Only Turkish — no EN/ES/DE dictionaries bundled (~10 KB gzip)
import { Terlik } from "terlik.js/tr";
// Or the factory from any sub-path
import { createTerlik } from "terlik.js/en";
const en = createTerlik({ mode: "strict" });
// Warm several languages at once
const cache = Terlik.warmup(["tr", "en", "es", "de"]);
cache.get("de").containsProfanity("scheiße"); // true
terlik.getMatches("$1kt1r git");
// [{
// word: "$1kt1r", root: "sik",
// index: 0, severity: "high",
// category: "sexual", method: "pattern"
// }]
terlik.clean("siktir git", { maskStyle: "partial" }); // "s****r git"
terlik.clean("siktir git", { maskStyle: "replace" }); // "[***] git"
const terlik = new Terlik({
language: "tr", // "tr" | "en" | "es" | "de"
mode: "balanced", // "strict" | "balanced" | "loose"
maskStyle: "stars", // "stars" | "partial" | "replace"
customList: ["customword"], // extra words to detect
whitelist: ["safeword"], // extra words to allow
minSeverity: "medium", // drop low-severity matches
excludeCategories: ["slur"], // skip whole categories
backgroundWarmup: true, // compile patterns off the hot path
});
MIT licensed · zero dependencies · contributions & new language packs welcome
// a normalization + pattern engine