npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@salem-qahtani/arabic-profanity

v0.1.0

Published

Arabic + English (incl. Arabizi) profanity classifier with injectable word lists.

Readme

@salem-qahtani/arabic-profanity

A profanity classifier for Arabic, English and Arabizi (Arabic written in Latin letters and digits). It returns a verdict (allow, flag or block) and can mask what it matched. It handles the evasions that defeat naive word lists: stretched letters (fuuuck, كسسس), invisible characters inside words, Arabic diacritics and tatweel, interchangeable Arabic letter forms, fullwidth and compatibility characters, and words spelled out with spaces (f u c k, ك س ي).

You bring the word lists. The package ships the engine and no word lists. For English, it uses obscenity's English dataset as a default flag tier, so English works out of the box; the default can be replaced or turned off. For Arabic, the word lists section documents a contributed starting point.

npm install @salem-qahtani/arabic-profanity

Requires Node.js 20 or later (or any modern JavaScript runtime). It ships ESM and CommonJS builds with TypeScript types.

Quick start

import { createFilter } from "@salem-qahtani/arabic-profanity";

const filter = createFilter({
  enBlock: ["badword"],         // English words to block outright
  arBlock: ["مثال"],            // Arabic words to block outright (exact word match)
  arFlag: ["تجربة"],            // Arabic words to flag for review (written naturally; folded for you)
  arabiziFlag: ["5ara"],        // Arabizi spellings to flag for review
});

filter.classify("some text");
// → { action: "allow" } | { action: "block" } | { action: "flag", source: "en" | "ar" | "arabizi" }

filter.moderate("that is b a d w o r d");
// → { verdict: { action: "flag", source: "en" }, masked: "that is ****" }

Create the filter once (at startup or module scope) and reuse it: createFilter compiles every list into matchers, and classify / moderate are then pure, synchronous and fast.

Verdicts and tiers

| Verdict | Meaning | What typically triggers it | | --- | --- | --- | | block | Tier 1: an unambiguous list hit. Safe to act on without a human. | A word in enBlock or arBlock. | | flag | Tier 2: a broader, fuzzier or heuristic hit. Accept it but hold it for review, or mask it. | obscenity's English dataset, arFlag, arabiziFlag, a spaced-out word, or a stretched Arabic block word. | | allow | Nothing matched. | |

When several things match, the highest tier wins. A flag verdict says which matcher fired (source: "en" | "ar" | "arabizi"), so you can route it.

A verdict never contains the matched word, its position or its length. That is deliberate: you can't accidentally echo a list entry back to a user, which would leak your list and coach people on how to evade it. If you need to show the user something, use the masked text.

How each list matches:

  • enBlock and arabiziFlag match whole Latin tokens and tolerate stretching. fuck also matches fuuuck and fuckkk, and koss matches kossss. Every run of identical letters must keep at least its listed length, so an entry with a genuine double letter (nigger) does not match the one-letter niger.
  • arBlock matches whole Arabic words exactly, after folding (see Normalization). That is what lets it block without review. Because the match is exact, a stretched form of a block word (زفتتت) misses the block tier. It is caught by the flag tier instead, and never silently blocked.
  • arFlag (and every arBlock entry) also match Arabic words under a parity rule: each run of a letter must have exactly its listed length, or be stretched to at least two more. A genuine doubled letter is exactly two, while a stretch is usually three or more. So a single-letter entry such as مل never matches the innocent doubled ممل, but كسسس does match كس. The cost is that a stretch of exactly two (كسس) is not caught.
  • Spaced-out words. A run of at least spacedMinRun (default 3) single letters separated only by spaces or punctuation is joined and re-tested at the flag tier only. A heuristic never blocks.
  • Matching is always by whole word, never by substring. Inflected or compound forms need their own entries. The English default (obscenity) is the exception: it does its own fuzzy matching.

Masking

moderate(text) returns { verdict, masked }. In masked, every matched region is replaced by exactly ****, whatever the length of the word, so the length isn't revealed either.

filter.moderate("fuck this shit");    // masked: "**** this ****"
filter.moderate("f.u.c.k");           // masked: "****"     (separators are part of the region)
filter.moderate("👍👍fuck👍👍");       // masked: "👍👍****👍👍"
filter.moderate("a perfectly fine day");  // masked is the input, unchanged
  • Choosing tiers. mask: "block" | "flag" | "both" (default "both") picks which tiers are masked. Matches that overlap are one match seen by two matchers, so they merge into one region that takes the highest tier involved. With mask: "flag", a word on a block list therefore stays visible even if a flag pattern also matched it. Matches that only touch keep their own tiers, so a flag word written right up against a block word is still masked under "flag". Masked regions that end up touching are shown as a single ****.
  • Positions are exact. The matchers see normalized text, but masking maps every position back to your original input, through every normalization step. Masks never split a character, an emoji or a combining sequence (see the next section for the one runtime caveat). If a match covers only part of a character that normalization expanded (for example ﷺ, which expands to a whole phrase), the whole original character is masked.
  • The verdict never changes. moderate(text).verdict is always identical to classify(text). classify is cheaper, so use it when you don't need the mask.

When the whole input comes back as ****

The library masks the entire input whenever it cannot be sure where a match is, rather than risk masking the wrong characters or leaving the match visible. Your verdict is unaffected, but a user would see their whole comment replaced by ****. There are two situations where this happens.

1. A custom English matcher that can't say where it matched. If you supply your own english matcher without spans, or its spans returns anything invalid, every English hit masks the whole input. The default matcher always reports its spans, so this only applies to custom matchers.

2. Segmentation that doesn't line up with normalization. Masking cuts the input into grapheme clusters using Intl.Segmenter, and checks on every call that this lines up with the normalized text. With Intl.Segmenter available, a mismatch effectively never happens. It is available in Node.js 20+ (official builds include full ICU), Deno, Bun, Chrome and Edge 87+, Safari 14.1+ and Firefox 125+.

Without Intl.Segmenter, the library approximates clusters itself: each code point, with any following combining marks, joiners, variation selectors and skin-tone modifiers attached. That handles accents (e + U+0301), Arabic diacritics and emoji. The approximation does not group characters that compose across separate code points, such as conjoining Hangul jamo. If a match lands in text like that, the whole input is masked. Some complex Indic and Southeast Asian clusters can also be split, which is cosmetic: a mark next to a **** may end up on its own. Runtimes where this applies:

  • Firefox older than 125.
  • Node.js built without ICU (--with-intl=none).
  • Some embedded or mobile JavaScript engines, such as Hermes in React Native, depending on version.

If you target one of these, load an Intl.Segmenter polyfill such as @formatjs/intl-segmenter before your first moderate call. You can check with typeof Intl.Segmenter === "function". classify doesn't use segmentation and works the same everywhere.

Normalization

Before matching, the text goes through these steps:

  1. NFKC. Folds compatibility characters: fullwidth fuck becomes fuck, the ligature fi becomes fi, and Arabic presentation forms become ordinary letters.
  2. Invisible characters are removed wherever they appear. That means every Unicode default-ignorable code point: zero-width spaces and joiners, directional marks and controls (including the Arabic Letter Mark), the soft hyphen, the word joiner, variation selectors and tag characters. The Arabic tatweel (ـ) is removed too. None of these change how a word looks, so a word is matched as the reader sees it. The flip side: an invisible character placed between two words no longer separates them.
  3. Arabic folding. Diacritics (harakat) are removed. أ إ آ ٱ become ا, ة becomes ه, and ى becomes ي.
  4. Latin lowercasing. Digits are kept, because Arabizi uses them for letters: 7 for ح, 3 for ع, 5 for خ.

List entries go through the same steps when the filter is built, so you can write them in their natural spelling, with diacritics, tatweel, ة, presentation forms or fullwidth letters. An entry that could never match throws a RangeError from createFilter, naming the list and index but not the entry. Examples: a phrase with a space (moby dick), a symbol (f*ck), an accented Latin letter (fück), or a script that doesn't belong in that list. Matching is by single word, and Latin tokens are a-z and 0-9 only, so such an entry would otherwise sit in your list doing nothing.

Configuration

| Option | Default | Description | | --- | --- | --- | | enBlock | [] | Latin words to block. Whole token, tolerates stretching. | | arBlock | [] | Arabic words to block. Exact whole word after folding. Also covered by the flag parity rule, so stretched forms are flagged. | | arFlag | [] | Arabic words to flag, using the parity rule. | | arabiziFlag | [] | Arabizi spellings to flag. Whole token, tolerates stretching. | | tokenWhitelist | [] | Exact normalized words that no word-list check will match, in either tier. It does not reach the English matcher, which reads whole text rather than words; use enWhitelist for English false positives. | | enWhitelist | [] | Phrases added to the default English matcher's own whitelist (for example "cockpit"). Ignored if you supply english. | | english | obscenity | The English flag-tier matcher: { hasMatch(text), spans?(text) }, or false to disable it. Without spans, or if spans returns anything invalid, an English hit still counts toward the verdict and moderate masks the whole input (it can't tell where the match is). | | spacedMinRun | 3 | Minimum number of spaced single letters that are joined and re-tested. At 2, any pair of isolated letters becomes a candidate, so lower it only after measuring against your own lists. | | mask | "both" | Which tiers moderate masks: "block", "flag" or "both". |

defaultEnglishMatcher(extraWhitelist?) is exported, so you can wrap or extend the default English matcher.

Security notes

  • Keep your lists on the server. The engine itself is safe to run anywhere, but any list you bundle into client-side code is public to anyone who opens the developer tools.
  • Cap input length yourself. There is no built-in length limit. Every pattern is anchored and avoids ambiguous repetition, so there is no catastrophic backtracking. Cost grows linearly with input length times list size, because every word is tested against every pattern; the test suite runs 200,000-character inputs. NFKC can expand some characters (for example ﷺ) to many times their length. moderate also builds an index map over the input whenever something matches, so it costs several times more than classify in time and memory. Limit untrusted input to what your field actually allows.
  • What masking reveals. masked shows where every match is, though not its length. That makes one moderate call a list-membership test for every word in the input at once. Someone shown their own masked text can paste thousands of candidate words, including stretched spellings, and learn in a single request which are on your list. With mask: "block" or "flag", they also learn which tier each word is on. Any per-request rate limit is therefore far weaker against masked output than against a plain accept or reject. If your lists are sensitive, show masked text to other readers but not back to its author, or limit by input size or by the number of masked regions.
  • This is one layer. Keyword matching can't understand context, sarcasm or images. Combine it with user reports and human review.

Known limitations

These are planned for later releases:

  • Latin letters with accents split a word into separate tokens: fück is seen as f + ck. English hits may still be caught by the obscenity tier.
  • Persian and Urdu letter variants that look like Arabic letters (ک for ك, ی for ي) are not yet folded. The same goes for Arabic-Indic digits in Arabizi.
  • Text is matched in the order it is stored, not the order it is displayed. Bidirectional override controls are stripped, but a word written backwards and displayed forwards by such a control is still seen backwards.
  • Partially spaced words (fu ck), and spaced runs shorter than spacedMinRun, are not joined.
  • A neighbouring one-letter word joins a spaced run: in what a b a d w o r d, the word a is joined too, giving abadword, so the spaced word is missed.

Word lists

The lists below are contributed by the package author as documentation. They are not package defaults, and nothing here is loaded unless you copy it into your config. They were compiled by a native Arabic speaker for one platform's moderation. They lean towards dialect and slang, and are neither exhaustive nor neutral: every community should review and adapt them.

Entries are already in folded form: no diacritics, ه instead of ة, ي instead of ى, and no tatweel. The one exception is two stretched spellings that keep ى on purpose. They are folded when the filter is built, like any entry. Matching is by whole word, so the forms with the definite article ال are separate words. Add them with a helper:

const withArticle = (words: string[]) => [...words, ...words.map((w) => "ال" + w)];

Starter list: explicit profanity

Explicit sexual, scatological and vulgar terms, with little or no innocent use. They are suitable for arBlock, for example arBlock: withArticle(STARTER_AR_BLOCK).

export const STARTER_AR_BLOCK = [
  "قحبه", "قحبتي", "قحاب", "مقحبه", "قحيب", "قحبون", "قحبتك", "قحبتكم",
  "قحبتنا", "قحبتهم", "قحبتهما", "تتمقحب", "يتمقحب", "اتمقحب", "مقاحيب", "يمقحبهم",
  "يمقحبهن", "متمقحبه", "متمقحب", "عاهره", "عاهرتي", "عواهر", "عاهرات", "عهر",
  "عاهرتنا", "عاهرتهم", "عاهرتك", "عاهرتهما", "يمعهرهم", "يمعهرهن", "معهره", "تتمعهر",
  "يتمعهر", "متمعهر", "متمعهره", "اتمعهر", "شرموطه", "شرموطتي", "شرموطتك", "شرموطتنا",
  "متشرمط", "متشرمطه", "شرموطتهم", "شرومطتكم", "شرموطتهما", "تتشرمط", "يتشرمط", "شرموطهم",
  "شرمطونا", "شرموطني", "اتشرمط", "شرمطه", "يشرمطهم", "يشرمطهن", "متناك", "تتناك",
  "بنيك", "يتناك", "بيتناك", "منيوك", "ناك", "ناكو", "ناكوا", "ينيكون",
  "حينيكون", "سينيكون", "بينيكون", "ناكوهم", "ناكونا", "ناكوني", "ناكوك", "حيتناك",
  "ينيكهن", "ينيكهم", "نيك", "زب", "زبي", "زبه", "زبك", "زبكما",
  "زبكم", "زبنا", "ازباب", "خصاوي", "كس", "كسي", "كسها", "كسهم",
  "كسك", "كسهما", "كسهن", "اكساس", "اكساسهم", "اكساسهن", "اكساسهما", "كسيس",
  "كسم", "كسمك", "كسبوك", "كسختك", "كسخوك", "كسخالتك", "كسجدك", "كسجدتك",
  "كسمها", "كسمي", "كسوجهك", "كسوجهي", "كسختي", "كسخوي", "كسبوي", "ديوث",
  "ديوت", "ديوثه", "دياثه", "ديوته", "دياته", "مديثه", "مديته", "اديث",
  "اديت", "مديث", "مديت", "عرص", "معرص", "نغل", "تجليخ", "جلخ",
  "سكس", "طيز", "طيزه", "اطياز", "طيزها", "طيزهن", "طيزهم", "طيزي",
  "فقحه", "فكحه", "فقحتها", "فكحتها", "فقحتهم", "فكحتهم", "ممحون", "يتمحن",
  "تتمحن", "اتمحن", "ممحونه", "مماحين", "ممحونات", "ممحونين", "ديد", "داعر",
  "داعره", "يمصه", "يلعنكسمك", "كىىىى", "كىىىمك",
];

Arabizi spellings, suitable for arabiziFlag:

export const STARTER_ARABIZI = [
  "kos", "87ba", "g7ba", "zby", "zbe", "zbi", "ksmk", "anek",
];

Words with legitimate, non-abusive uses

This platform blocked the words below as well, but each one also has real, everyday or serious use, which is why none of them is in the starter list. Decide per community. Flagging them for human review is the safer choice.

Exact collisions with everyday words. محنه ("ordeal, tribulation"), كسكسه ("couscous") and ثدي ("breast", the standard anatomical word) are spelled exactly like a vulgar word and an everyday one. The Arabic block tier matches whole words exactly, so blocking these blocks those exact everyday words too, and nothing beyond them. This platform accepted that trade:

export const COLLISIONS_AR_BLOCK = [
  "كسكسه", "محنه", "ثدي",
];

Vulgar in slang, standard elsewhere. قضيب also means "rod" or "rail", and زغب means "fluff" or "down". مازوخي is a clinical term, and دعاره is the standard word for prostitution. اغتصاب is not slang at all: it is the standard word for rape. It is left out of the starter list because it appears constantly in news, reviews and serious discussion, and blocking it would silence exactly those conversations:

export const LEGITIMATE_USE_AR_BLOCK = [
  "اغتصاب", "يغتصبني", "يغتصب", "اغتصب", "اغتصبهم", "مغتصب", "اغتصبهما", "اغتصبتهما",
  "اغتصبتهم", "يغتصبهم", "يغتصبهما", "يغتصبهن", "تغتصب", "تغتصبهم", "تغتصبهن", "تغتصبهما",
  "مغتصبه", "قضيب", "قضيبه", "قضيبي", "قضيبنا", "قضيبهم", "اقضبتنا", "مازوخي",
  "مازوخيه", "زغب", "يزغب", "مزغوب", "تزغب", "زاغب", "دعاره",
];

Arabizi spellings with innocent collisions that this platform flagged. ks is a common abbreviation, m9 is also a pistol and a camera model, and arkb means "I ride":

export const AMBIGUOUS_ARABIZI = [
  "ks", "m9", "arkb",
];

Not published: religious, family and identity terms

The platform these lists come from also flags a broader set covering religious, family and identity terms, because they turn up in compound insults. Whether to match those is a per-platform decision, and keyword matching in these categories produces heavy review-queue volume, because the same words are used innocently all the time. They are not published here: if you want that behaviour, build the set for your own audience and dialect.

License

MIT. The default English matcher is obscenity (MIT), installed as a dependency.