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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@fevo-tech/obscenity

v0.0.8

Published

A robust profanity and obscenity filtering library for JavaScript and TypeScript applications, designed to detect and censor offensive language effectively.

Downloads

715

Readme

@fevo/obscenity

A robust profanity and obscenity filtering library for Node.js, built on top of obscenity with extended dictionaries and HTML support.

Features

  • 🔍 Detect profanity in text strings
  • 🔒 Censor bad words with customizable strategies
  • 🌐 HTML-aware censoring that preserves HTML tags
  • 📚 Extended dictionary including racial slurs, LGBTQ+ slurs, and other offensive terms
  • Fast and efficient using RegExp-based matching
  • 🎯 TypeScript support with full type definitions

Installation

npm install @fevo/obscenity

Usage

Basic Text Censoring

import { censorBadWords, hasContainsBadWords } from "@fevo/obscenity";

// Censor bad words in a string
const text = "This is a test with some bad words";
const censored = censorBadWords(text);
console.log(censored); // "This is a test with some b** words"

// Check if text contains bad words
const hasProfanity = hasContainsBadWords(text);
console.log(hasProfanity); // true or false

HTML Censoring

The library can censor bad words in HTML content while preserving all HTML tags and structure:

import { censorHtmlPreservingTags } from "@fevo/obscenity";

const html = "<p>This has some <strong>bad words</strong> in it</p>";
const censoredHtml = censorHtmlPreservingTags(html);
console.log(censoredHtml);
// Output: '<p>This has some <strong>b** words</strong> in it</p>'

API Reference

censorBadWords(input: string): string

Censors profanity in the input string by replacing offensive words with asterisks, keeping the first character.

Parameters:

  • input - The text string to censor

Returns:

  • A string with profanity censored

Example:

censorBadWords("bad word here"); // "b** word here"

hasContainsBadWords(input: string): boolean

Checks whether the input string contains any profanity.

Parameters:

  • input - The text string to check

Returns:

  • true if profanity is found, false otherwise

Example:

hasContainsBadWords("clean text"); // false
hasContainsBadWords("profane text"); // true

censorHtmlPreservingTags(htmlStr: string): string

Censors profanity in HTML content while preserving all HTML tags, attributes, and structure.

Parameters:

  • htmlStr - The HTML string to censor

Returns:

  • A string with profanity censored but HTML structure intact

Example:

censorHtmlPreservingTags("<div>bad word</div>");
// '<div>b** word</div>'

How It Works

The library uses:

  • obscenity library for core matching and censoring functionality
  • Custom extended dictionary with various categories of offensive terms
  • htmlparser2 for HTML parsing and tag preservation
  • RegExp-based matching with transformers for variant detection
  • Keep-start censoring strategy that preserves the first character and replaces the rest with asterisks

Dictionary Coverage

The extended dictionary includes:

  • Racial slurs (various ethnicities)
  • LGBTQ+ slurs
  • Gender-based slurs
  • Ableist terms
  • Sexual content
  • Religious slurs
  • And many other offensive terms with common variations

Development

Build

npm run build

Clean

npm run clean

Dependencies

License

ISC

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Disclaimer

This library is designed to help filter offensive content, but no automated system is perfect. The dictionary includes explicit terms for detection purposes only. Use responsibly and consider your specific use case and audience.