🇧🇷 Português | 🇺🇸 English | 🇪🇸 Español | 🇫🇷 Français | 🇩🇪 Deutsch | 🇮🇹 Italiano
Bad Word Filter is a simple multi-language and free web service for filtering and removing profanity, obscenity, and other unwanted text.
This package is available on npm:
https://www.npmjs.com/package/@menesesevandro/bad-word-filter-api
Install in your project:
npm i @menesesevandro/bad-word-filter-apinpm install
npm startThe API will be available at http://localhost:3000.
- Multi-language support: pt-br, en, es, fr, de, it, it
- Replace bad words with a customizable character or fixed word
- Supports GET and POST
- Add extra words to filter
- Ignores accents automatically
GET /filter
POST /filter
text(string or string array, required): text(s) to be filteredlang(string, optional): language (e.g., pt-br, en, es, fr, de, it). Default: enfill_char(string, optional): character to replace each letter of the profanity. Default:*fill_word(string, optional): fixed word to replace the profanity (e.g., "hidden"). If provided, takes precedence overfill_char.extras(string or array, optional): up to 10 extra words to filter, comma-separated or array
GET /filter?text=this is shit&lang=en&fill_char=#
Response:
{
"original_text": "this is shit",
"filtered_text": "this is ####",
"isFiltered": true,
"words_found": ["shit"],
"lang": "en",
"fill_char": "#",
"fill_word": null,
"extra_words": []
}GET /filter?text=this is shit&lang=en&fill_word=[hidden]
Response:
{
"original_text": "this is shit",
"filtered_text": "this is [hidden]",
"isFiltered": true,
"words_found": ["shit"],
"lang": "en",
"fill_char": "*",
"fill_word": "[hidden]",
"extra_words": []
}POST /filter
{
"text": "banana orange",
"extras": ["banana", "orange"],
"fill_char": "#"
}Response:
{
"results": {
"original_text": "banana orange",
"filtered_text": "##### ######",
"isFiltered": true,
"words_found": ["banana", "orange"]
},
"lang": "en",
"fill_char": "#",
"fill_word": null,
"extra_words": ["banana", "orange"]
}POST /filter
{
"text": [
"first text with curse",
"second clean text",
"third with banana"
],
"extras": ["banana"],
"fill_char": "#"
}Response:
{
"results": [
{
"original_text": "first text with curse",
"filtered_text": "first text with #####",
"isFiltered": true,
"words_found": ["curse"]
},
{
"original_text": "second clean text",
"filtered_text": "second clean text",
"isFiltered": false,
"words_found": []
},
{
"original_text": "third with banana",
"filtered_text": "third with #####",
"isFiltered": true,
"words_found": ["banana"]
}
],
"lang": "en",
"fill_char": "#",
"fill_word": null,
"extra_words": ["banana"]
}GET /languages
Response:
{
"languages": [
{
"code": "pt-br",
"name": "Português (Brasil)"
},
{
"code": "en",
"name": "English (USA)"
},
{
"code": "es",
"name": "Español (España)"
},
{
"code": "fr",
"name": "Français (France)"
},
{
"code": "de",
"name": "Deutsch (Deutschland)"
}
],
"default_lang": "en"
}Run all automated tests with:
npm testMIT
const axios = require('axios');
// Simple filter example
axios.get('http://localhost:3000/filter', {
params: {
text: 'badword here',
lang: 'en',
fill_char: '#'
}
}).then(res => console.log(res.data));
// Example with safe_words and statistics
axios.post('http://localhost:3000/filter', {
text: 'banana and orange are fruits',
extras: ['banana', 'orange'],
safe_words: ['banana'],
include_stats: true
}).then(res => console.log(res.data));import requests
# Simple filter
resp = requests.get('http://localhost:3000/filter', params={
'text': 'badword here',
'lang': 'en',
'fill_char': '#'
})
print(resp.json())
# With safe_words and statistics
resp = requests.post('http://localhost:3000/filter', json={
'text': 'banana and orange are fruits',
'extras': ['banana', 'orange'],
'safe_words': ['banana'],
'include_stats': True
})
print(resp.json())curl "http://localhost:3000/filter?text=badword%20here&lang=en&fill_char=#"
curl -X POST http://localhost:3000/filter \
-H "Content-Type: application/json" \
-d '{"text": "banana and orange are fruits", "extras": ["banana", "orange"], "safe_words": ["banana"], "include_stats": true}'{
"results": {
"original_text": "banana and orange are fruits",
"filtered_text": "banana and ###### are fruits",
"isFiltered": true,
"words_found": ["orange"],
"stats": {
"total_words": 5,
"total_characters": 29,
"filtered_words": 1,
"filtered_characters": 6,
"filter_ratio": 0.207,
"words_ratio": 0.2,
"safe_words_used": 1
}
},
"lang": "en",
"fill_char": "*",
"fill_word": null,
"extra_words": ["banana", "orange"],
"safe_words": ["banana"],
"aggregate_stats": {
"total_words": 5,
"total_characters": 29,
"filtered_words": 1,
"filtered_characters": 6,
"safe_words_used": 1,
"average_filter_ratio": 0.207,
"average_words_ratio": 0.2
}
}- Create a new file in
src/lang/with the language code, e.g.,xx.js. - Export an object with the following properties:
name: Language nameprofanityList: Array of profane wordsmessages: Error and warning messages (see examples in existing files)
- Follow the pattern of existing files (e.g.,
pt-br.js,en.js). - Open a PR or send your suggestion!