{"id":16644141,"url":"https://github.com/devxprite/profanity-cleaner","last_synced_at":"2025-06-17T04:36:26.012Z","repository":{"id":65704378,"uuid":"580763503","full_name":"devxprite/profanity-cleaner","owner":"devxprite","description":"JavaScript library that helps you censor bad words in a given text.","archived":false,"fork":false,"pushed_at":"2023-02-05T15:04:53.000Z","size":257,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-02T08:31:48.517Z","etag":null,"topics":["badword-filter","badwords","javascript","profanity","profanity-detection","profanity-filter"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/profanity-cleaner","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devxprite.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":["https://www.buymeacoffee.com/devxprite"]}},"created_at":"2022-12-21T11:42:10.000Z","updated_at":"2024-12-23T11:45:19.000Z","dependencies_parsed_at":"2023-02-19T00:15:58.736Z","dependency_job_id":null,"html_url":"https://github.com/devxprite/profanity-cleaner","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devxprite%2Fprofanity-cleaner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devxprite%2Fprofanity-cleaner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devxprite%2Fprofanity-cleaner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devxprite%2Fprofanity-cleaner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devxprite","download_url":"https://codeload.github.com/devxprite/profanity-cleaner/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238961330,"owners_count":19559468,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["badword-filter","badwords","javascript","profanity","profanity-detection","profanity-filter"],"created_at":"2024-10-12T08:10:33.504Z","updated_at":"2025-02-15T07:32:54.192Z","avatar_url":"https://github.com/devxprite.png","language":"JavaScript","funding_links":["https://www.buymeacoffee.com/devxprite"],"categories":[],"sub_categories":[],"readme":"## profanity-cleaner\n\nA simple and lightweight JavaScript library that helps you clean profane or inappropriate words from a given text. It provides a simple API that you can use to filter out bad words and replace them with asterisks or any other character of your choice. The library uses a predefined list of bad words that can be customized to fit your specific requirements.\n\n### Installation\nTo install the package, run the following command:\n\n```bash\nnpm install profanity-cleaner\n```\n\n## Usage\n\n### use in Browser\n\nUse directly in the browser with [jsDelivr](https://www.jsdelivr.com/package/npm/profanity-cleaner) or [unpkg](https://unpkg.com/profanity-cleaner/) by including the following script tag in your HTML file.\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n    \u003chead\u003e\n        \u003cmeta charset=\"utf-8\"\u003e\n        \u003ctitle\u003eProfanity Cleaner\u003c/title\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n        \u003cscript src=\"https://cdn.jsdelivr.net/npm/profanity-cleaner@latest\"\u003e\u003c/script\u003e\n        \u003cscript\u003e\n            const text = \"What the hell is going on?\";\n            const cleanedText = profanityCleaner.clean(text);\n\n            console.log(cleanedText) // What the **** is going on?\n        \u003c/script\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n\n### use as a module\nImport the clean function and call it with a string argument to censor bad words in the text.\n\n```javascript\nimport { clean } from 'profanity-cleaner';\n\nconst text = \"Don't be an ash0le\";\nconsole.log(clean(text)) // Don't be an ******\n```\n\n### Options\nYou can pass options to the clean function as a second argument. The following options are available:\n\n#### `placeholder`\n\n*Type* : `string`  \n*Default* : `*`\n\nThe character to use as a placeholder for the bad words.\n\n```javascript\nimport { clean } from 'profanity-cleaner';\n\nconst text = \"This is a funck!ng test\";\n\nconsole.log(clean(text, { placeholder: '#' })) \n// OUTPUT: This is a f####g test\n```\n\n#### `customReplacement`\n\n*Type* : `function`  \n*Default* : `null`\n\nA function that returns a string to replace the bad words with. The function is passed the bad word as an argument.\n\n```javascript\nimport { clean } from 'profanity-cleaner';\n\nconst text = \"This is a funck!ng test\";\n\nconsole.log(clean(text, { customReplacement: (word) =\u003e word.toUpperCase() }))\n// OUTPUT: This is a FUNCK!NG test\n```\n\n#### `keepFirstAndLastChar`\n\n*Type* : `boolean`  \n*Default* : `false`\n\nWhether to keep the first and last character of the bad word.\n\n```javascript\nimport { clean } from 'profanity-cleaner';\n\nconst text = \"This is a funck!ng test\";\n\nconsole.log(clean(text, { keepFirstAndLastChar: true }))\n// OUTPUT: This is a f****g test\n```\n\n#### `customMatch`\n\n*Type* : `function`  \n*Default* : `null`\n\nA function that returns a boolean to determine whether a word should be censored. The function is passed the bad word as an argument. In the following example, only words with an odd number of characters are censored.\n\n```javascript\nimport { clean } from 'profanity-cleaner';\n\nconst text = \"This is a funck!ng test\";\n\nconsole.log(clean(text, { customMatch: (word) =\u003e word.length % 2 != 0 }))\n// OUTPUT: This is a f*****g test\n```\n\n#### `exceptions`\n\n*Type* : `array`  \n*Default* : `[]`\n\nAn array of words that should not be censored. In the following example, the word `hell` is not censored.\n\n```javascript\nimport { clean } from 'profanity-cleaner';\n\nconst exceptionalWords = ['hell'];\nconst text = \"What the hell is going on?\";\n\nconsole.log(clean(text, { exceptions: exceptionalWords }))\n// OUTPUT: What the hell is going on?\n```\n\n#### `customBadWords`\n\n*Type* : `array`\n\nAn array of words that should be censored. In the following example, the word `bad` is censored.\n\n```javascript\nimport { clean } from 'profanity-cleaner';\n\nconst badWordsArray = ['bad', 'evil'];\nconst text = \"This is a bad example\";\n\nconsole.log(clean(text, { customBadWords: badWordsArray }))\n\n// OUTPUT: This is a *** example\n```\n\n\n## Credits\n* The list of bad words used in this library was sourced from the [badwords](https://github.com/web-mech/badwords) project.\n\n## License\n`profanity-cleaner` is released under the [MIT License](LICENSE).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevxprite%2Fprofanity-cleaner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevxprite%2Fprofanity-cleaner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevxprite%2Fprofanity-cleaner/lists"}