Skip to content

Getting started

Anti-Ttyah is a content filter for Arabic, Franco-arabe digit-speak, French, English, and Tamazight. It runs offline in Node 18+ and the browser.

Content warning. The package ships a list of offensive terms. That is the point. Guides on this site use starred patterns (9*ba) out of respect for the reader. Try real input in the playground. Arabic docs: العربية.

Install

bash
npm i anti-ttyah

Zero runtime dependencies.

Library

ts
import { contains, mask, inspect, explain, blockedError, createFilter } from "anti-ttyah";

contains("9*ba");               // true  (Franco-arabe, after you type a real token)
contains("ق*بة");               // true  (Arabic script)
mask("hello z*bi");             // "hello ****"
inspect("ولد الق*بة");
// { blocked: true, hits: [{ start, end, raw, lang, category }] }

explain("hello z*bi");
// tokens with lookup keys — useful for debugging

blockedError(title, body);      // { error: "PROFANITY_BLOCKED" } | null

We do not show the real listed words here, out of respect for the reader (9*ba).

Nous n’affichons pas les vrais mots listés ici, par respect pour le lecteur.

لم نذكر الكلمات الحقيقية هنا احتراماً للقارئ.

Custom filter

Extend or soften the default list without forking:

ts
const filter = createFilter({
  extraTerms: ["customslur"],
  extraPhrases: ["not allowed"],
  allowlist: ["h*ar"],          // skip a false positive
  maskChar: "#",
  maskStyle: "token",           // "***" instead of length-preserving
  categories: ["sexual", "slur"],
  matchSeparators: true,        // z.e.b.i / ze*bi (default)
});

filter.contains("hello");
filter.mask("hello");
filter.inspect("hello");
filter.explain("hello");

Aliases kept for drop-in use: containsProfanity, maskProfanity, profanityError.

CLI

bash
npx anti-ttyah "bonjour"
# clean   (exit 0)

npx anti-ttyah --mask "hello z*bi"
npx anti-ttyah --json "hello z*bi"
npx anti-ttyah --explain "hello z*bi"
npx anti-ttyah --categories sexual,insult "hello"
npx anti-ttyah --file comments.txt
echo "text" | npx anti-ttyah

Exit 1 if blocked — useful in CI. Exit 2 for usage errors.

See the API and recipes for more.

MIT license · runs in Node and the browser · zero runtime deps