badwords-ko
raw JSON → 1.0.4 verified Fri May 01 auth: no javascript maintenance
A Korean profanity filter library for Node.js and browser, v1.0.4 (current stable). Provides a Filter class with customizable placeholder, regex, and blacklist management (add/remove words). Supports ES6+ import syntax. Built as a Korean adaptation of the bad-words npm package. Lightweight, no dependencies, TypeScript definitions not shipped. Slow release cadence (last update 2022). Differentiator: specifically targets Korean profanity with a built-in blacklist of Korean curse words, unlike generic profanity filters.
Common errors
error const Filter = require('badwords-ko'); TypeError: Filter is not a constructor ↓
cause Requiring the module directly returns the module exports, not the default export.
fix
Use const Filter = require('badwords-ko').default;
error import Filter from 'badwords-ko'; SyntaxError: Cannot use import statement outside a module ↓
cause Using ES import syntax in a CommonJS environment without proper module configuration.
fix
Add 'type': 'module' to package.json or use .mjs extension.
error filter.clean('some string') returns same string even when profane words present ↓
cause Possibly empty blacklist if (emptyList: true) or words not added.
fix
Ensure you don't set emptyList: true unless you intend to add words later. Use new Filter() without options.
Warnings
deprecated Package uses deprecated 'bad-words' as reference; original package no longer maintained. ↓
fix Consider using 'bad-words-next' or build your own filter for better maintainability.
gotcha Constructor accepts 'regex' option but actually uses 'replaceRegex' for replacement; 'regex' is for sanitization before matching. ↓
fix Use 'replaceRegex' option to control replacement regex, not 'regex'.
gotcha Calling addWords/removeWords with a single array will treat array as one word; use spread operator. ↓
fix Use filter.addWords(...list) instead of filter.addWords(list).
breaking Package is ESM-only and does not export a CommonJS module; requires transpiler or Node.js >=16 with type: module. ↓
fix Use ES modules or set project to type: module. Alternatively, use dynamic import() in CommonJS.
Install
npm install badwords-ko yarn add badwords-ko pnpm add badwords-ko Imports
- Filter wrong
const Filter = require('badwords-ko')correctimport Filter from 'badwords-ko' - Filter (named import) wrong
const { Filter } = require('badwords-ko');correctimport { Filter } from 'badwords-ko' - require (CommonJS) wrong
const Filter = require('badwords-ko');correctconst Filter = require('badwords-ko').default
Quickstart
import Filter from 'badwords-ko';
const filter = new Filter();
console.log(filter.isProfane('시발')); // true
console.log(filter.clean('욕을 합니다 개새끼')); // '욕을 합니다 ***'
const customFilter = new Filter({ placeHolder: 'x', list: ['나쁜'] });
customFilter.addWords('무진장');
console.log(customFilter.clean('무진장 나쁜 말!')); // 'xxxx xxx 말!'
filter.removeWords('시발');
console.log(filter.clean('시발')); // '시발' (no longer filtered)