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

arabic-profanity-filter

v0.1.3

Published

Configurable Arabic word and phrase profanity checking for browsers and Node.js

Readme

Arabic profanity filter

A zero-dependency Arabic word and phrase checker for React, other browser apps, and Node.js. Includes ESM, CommonJS, and TypeScript declarations. No network requests or user-text collection.

Installation

npm install arabic-profanity-filter

Supports browsers (through a bundler), React, and Node.js, with ESM, CommonJS, and TypeScript declarations. No runtime dependencies.

Usage

import { createArabicProfanityFilter } from 'arabic-profanity-filter';

const filter = createArabicProfanityFilter({
  additionalWords: ['عبارة محظورة'],
  allowlist: [],
});

filter.isProfane('اشتراك شهري'); // false
filter.check('عبارة محظورة');
// { isProfane: true, matches: ['عبارة محظورة'], normalizedText: 'عبارة محظورة' }

Provide words: [...] to replace the starter dictionary entirely. additionalWords extends it. allowlist removes exact normalized dictionary entries; it does not exempt a whole sentence containing other blocked words. Options are copied when the filter is created. Non-string text and invalid word lists throw TypeError.

React example

Create the filter once outside your component. Show feedback after the field has been touched, and recheck on submit:

import { useState } from 'react';
import { createArabicProfanityFilter } from 'arabic-profanity-filter';

const filter = createArabicProfanityFilter();

export function ArabicDescription({ onSave }) {
  const [text, setText] = useState('');
  const [touched, setTouched] = useState(false);
  const invalid = filter.isProfane(text);

  function submit(event) {
    event.preventDefault();
    setTouched(true);
    if (filter.isProfane(text)) return;
    onSave(text);
  }

  return (
    <form onSubmit={submit}>
      <label htmlFor="arabic-description">الوصف بالعربية</label>
      <textarea
        id="arabic-description"
        dir="rtl"
        value={text}
        onChange={event => setText(event.target.value)}
        onBlur={() => setTouched(true)}
        aria-invalid={touched && invalid}
        aria-describedby={touched && invalid ? 'description-error' : undefined}
      />
      {touched && invalid && (
        <p id="description-error" role="alert">
          يحتوي النص على ألفاظ غير مسموح بها. يرجى تعديله.
        </p>
      )}
      <button type="submit">حفظ</button>
    </form>
  );
}

Matching policy and limits

  • Normalizes a copy with Unicode NFKC, strips combining marks, invisible format characters and Arabic elongation, folds alef variants and final alef maqsura, and lowercases text. Original input is never modified.
  • Matches complete letter/number tokens and adjacent phrases. Punctuation is a separator, so a phrase can match across punctuation or line breaks.
  • Does not use JavaScript \b boundaries, which do not represent Arabic words.
  • The starter list covers explicit sexual profanity, common insults, and curse phrases across major Arabic dialects, including ta marbuta and ha spellings. It is not a complete Arabic dictionary, toxicity model, or dialect benchmark. Review it with native speakers against your product policy before use.
  • Does not automatically expand Arabic prefixes/suffixes, Arabizi, repeated letters, or words split with punctuation. Add reviewed variants explicitly.
  • Context can change meaning; exact matching can still produce false positives. Test real product names and descriptions, and adjust the list accordingly.
  • Frontend validation is bypassable. Enforce equivalent rules in your backend. This package can also run on Node.js for server-side validation.

Development

Run the tests and preview the package contents:

npm test
npm pack --dry-run

License

MIT — see LICENSE.