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

profanity-guard

v1.0.7

Published

A fast, zero-dependency, highly extendable profanity filter for Node.js, React, Next.js, and Vanilla JS.

Readme

Profanity Guard

A blazingly fast, zero-dependency, and highly extendable profanity filter for the modern web. Built with TypeScript for a seamless developer experience in React, Next.js, Node.js, and vanilla JavaScript.

npm version License: MIT

Features

  • Performance-First: Uses O(1) Set lookups and optimized tokenization.
  • Leet-Speak Detection: Automatically catches bypasses like b!tch, a$$hole, or f*ck.
  • Scunthorpe Proof: Smart logic prevents false positives for words like "button" or "classic".
  • Zero Dependencies: Lightweight footprint for both frontend and backend.
  • First-class TypeScript: Built-in type definitions for perfect autocompletion.
  • Fully Extendable: Create custom instances to add your own banned words or whitelist specific terms.

Installation

npm install profanity-guard
# or
yarn add profanity-guard

Usage

1. Simple Usage (Default)

Import the ready-to-use function for standard filtering using the built-in dictionary of 300+ words.

import { profanityCheck } from 'profanity-guard'

// Simple boolean checks
const isOffensive = profanityCheck('This is some bullsh!t')
console.log(isOffensive) // true

const isClean = profanityCheck('Have a wonderful day!')
console.log(isClean) // false

2. Custom Extension

Use the ProfanityEngine class to tailor the filter to your application's specific needs. This is useful for adding domain-specific slang or whitelisting words.

import { ProfanityEngine } from 'profanity-guard'

const myGuard = new ProfanityEngine({
	addWords: ['custom-bad-word', 'competitor-name'], // Add unique banned words
	removeWords: ['hell', 'booty'], // Allow words filtered by default
})

export const checkText = (input: string) => myGuard.check(input)

Framework Examples

React (Real-time Validation)

Prevent inappropriate usernames or comments directly in the UI.

import React, { useState } from 'react'
import { profanityCheck } from 'profanity-guard'

export function Registration() {
	const [error, setError] = useState('')

	const handleInput = (e: React.ChangeEvent<HTMLInputElement>) => {
		const value = e.target.value

		// Check for profanity on every keystroke
		if (profanityCheck(value)) {
			setError('Username contains inappropriate language.')
		} else {
			setError('')
		}
	}

	return (
		<div>
			<input
				type='text'
				onChange={handleInput}
				placeholder='Enter Username'
			/>
			{error && <p style={{ color: 'red', fontSize: '12px' }}>{error}</p>}
		</div>
	)
}

Next.js (API Route Protection)

Sanitize user-generated content on the server side before database entry.

// app/api/comment/route.ts
import { NextResponse } from 'next/server'
import { profanityCheck } from 'profanity-guard'

export async function POST(request: Request) {
	const { content } = await request.json()

	if (profanityCheck(content)) {
		return NextResponse.json(
			{ error: 'Content violates community guidelines.' },
			{ status: 400 },
		)
	}

	// Safe to proceed with database logic...
	return NextResponse.json({ success: true })
}

Configuration Options

| Option | Type | Description | | ------------- | ---------- | -------------------------------------------------------- | | addWords | string[] | Array of words to add to the blacklist. | | removeWords | string[] | Array of words to remove (whitelist) from the blacklist. |

License

MIT © 2026 Akshay Benny