{"id":13809258,"url":"https://github.com/jo3-l/obscenity","last_synced_at":"2025-06-22T17:30:40.124Z","repository":{"id":37032250,"uuid":"354938781","full_name":"jo3-l/obscenity","owner":"jo3-l","description":"Robust, extensible profanity filter for Node.js","archived":false,"fork":false,"pushed_at":"2025-06-21T02:53:58.000Z","size":2338,"stargazers_count":115,"open_issues_count":12,"forks_count":7,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-21T03:38:08.406Z","etag":null,"topics":["antiswear","bad-words","obscene","obscenity","profane","profanity","swear-filter","swear-filtering","swearing","swearwords"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/jo3-l.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-04-05T18:51:05.000Z","updated_at":"2025-06-21T02:51:58.000Z","dependencies_parsed_at":"2024-01-12T07:24:23.801Z","dependency_job_id":"b6011cf6-1074-4b22-9f35-cae70336739f","html_url":"https://github.com/jo3-l/obscenity","commit_stats":{"total_commits":169,"total_committers":3,"mean_commits":"56.333333333333336","dds":"0.023668639053254448","last_synced_commit":"cd1af581e8c2f3fe283f494940c8905762a18c38"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/jo3-l/obscenity","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jo3-l%2Fobscenity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jo3-l%2Fobscenity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jo3-l%2Fobscenity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jo3-l%2Fobscenity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jo3-l","download_url":"https://codeload.github.com/jo3-l/obscenity/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jo3-l%2Fobscenity/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261333480,"owners_count":23143148,"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":["antiswear","bad-words","obscene","obscenity","profane","profanity","swear-filter","swear-filtering","swearing","swearwords"],"created_at":"2024-08-04T01:02:13.296Z","updated_at":"2025-06-22T17:30:35.109Z","avatar_url":"https://github.com/jo3-l.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Obscenity\n\n\u003e Robust, extensible profanity filter for NodeJS.\n\n\u003ca href=\"https://github.com/jo3-l/obscenity/actions\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/jo3-l/obscenity/.github/workflows/continuous-integration.yml?branch=main\u0026style=for-the-badge\" alt=\"Build status\"\u003e\u003c/a\u003e\n\u003ca href=\"https://app.codecov.io/gh/jo3-l/obscenity/\"\u003e\u003cimg src=\"https://img.shields.io/codecov/c/github/jo3-l/obscenity?style=for-the-badge\" alt=\"Codecov status\"\u003e\u003c/a\u003e\n\u003ca href=\"https://npmjs.com/package/obscenity\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/obscenity?style=for-the-badge\" alt=\"npm version\"\u003e\u003c/a\u003e\n\u003cimg src='https://img.shields.io/github/languages/top/jo3-l/serenity.svg?style=for-the-badge' alt='Language'/\u003e\n\u003ca href=\"https://github.com/jo3-l/obscenity/blob/main/LICENSE.md\"\u003e\u003cimg src=\"https://img.shields.io/github/license/jo3-l/obscenity?style=for-the-badge\" alt=\"License\"\u003e\u003c/a\u003e\n\n## Why Obscenity?\n\n- **Accurate:** Though Obscenity is far from perfect (as with all profanity filters), it makes reducing false positives as simple as possible: adding whitelisted phrases is as easy as adding a new string to an array, and using word boundaries is equally simple.\n- **Robust:** Obscenity's transformer-based design allows it to match on variants of phrases other libraries are typically unable to, e.g. `fuuuuuuuckkk`, `ʃṳ𝒸𝗄`, `wordsbeforefuckandafter` and so on. There's no need to manually write out all the variants either: just adding the pattern `fuck` will match all of the cases above by default.\n- **Extensible:** With Obscenity, you aren't locked into anything - removing phrases that you don't agree with from the default set of words is trivial, as is disabling any transformations you don't like (perhaps you feel that leet-speak decoding is too error-prone for you).\n\n## Installation\n\n```shell\n$ npm install obscenity\n$ yarn add obscenity\n$ pnpm add obscenity\n```\n\n## Example usage\n\nFirst, import Obscenity:\n\n```javascript\nconst {\n\tRegExpMatcher,\n\tTextCensor,\n\tenglishDataset,\n\tenglishRecommendedTransformers,\n} = require('obscenity');\n```\n\nOr, in TypeScript/ESM:\n\n```typescript\nimport {\n\tRegExpMatcher,\n\tTextCensor,\n\tenglishDataset,\n\tenglishRecommendedTransformers,\n} from 'obscenity';\n```\n\nNow, we can create a new matcher using the English preset.\n\n```javascript\nconst matcher = new RegExpMatcher({\n\t...englishDataset.build(),\n\t...englishRecommendedTransformers,\n});\n```\n\nNow, we can use our matcher to search for profanities in the text. Here's two examples of what you can do:\n\n**Check if there are any matches in some text:**\n\n```javascript\nif (matcher.hasMatch('fuck you')) {\n\tconsole.log('The input text contains profanities.');\n}\n// The input text contains profanities.\n```\n\n**Output the positions of all matches along with the original word used:**\n\n```javascript\n// Pass \"true\" as the \"sorted\" parameter so the matches are sorted by their position.\nconst matches = matcher.getAllMatches('ʃ𝐟ʃὗƈｋ ỹоứ 𝔟ⁱẗ𝙘ɦ', true);\nfor (const match of matches) {\n\tconst { phraseMetadata, startIndex, endIndex } =\n\t\tenglishDataset.getPayloadWithPhraseMetadata(match);\n\tconsole.log(\n\t\t`Match for word ${phraseMetadata.originalWord} found between ${startIndex} and ${endIndex}.`,\n\t);\n}\n// Match for word fuck found between 0 and 6.\n// Match for word bitch found between 12 and 18.\n```\n\n**Censoring matched text:**\n\nTo censor text, we'll need to import another class: the `TextCensor`.\nSome other imports and creation of the matcher have been elided for simplicity.\n\n```javascript\nconst { TextCensor, ... } = require('obscenity');\n// ...\nconst censor = new TextCensor();\nconst input = 'fuck you little bitch';\nconst matches = matcher.getAllMatches(input);\nconsole.log(censor.applyTo(input, matches));\n// %@$% you little **%@%\n```\n\nThis is just a small slice of what Obscenity can do: for more, check out the [documentation](#documentation).\n\n## Accuracy\n\n\u003e **Note:** As with all swear filters, Obscenity is not perfect (nor will it ever be). Use its output as a heuristic, and not as the sole judge of whether some content is appropriate or not.\n\nWith the English preset, Obscenity (correctly) finds matches in all of the following texts:\n\n- you are a little **fuck**er\n- **fk** you\n- **ffuk** you\n- i like **a$$es**\n- \u003c!-- prettier-ignore --\u003e ʃ𝐟ʃὗƈｋ ỹоứ\n\n...and it **does not match** on the following:\n\n- the **pen is** mightier than the sword\n- i love banan**as s**o yeah\n- this song seems really b**anal**\n- g**rape**s are really yummy\n\n## Documentation\n\nFor a step-by-step guide on how to use Obscenity, check out the [guide](./docs/guide).\n\nOtherwise, refer to the [auto-generated API documentation](./docs/reference).\n\n## Contributing\n\nIssues can be reported using the [issue tracker](https://github.com/jo3-l/obscenity/issues).\nIf you'd like to submit a pull request, please read the [contribution guide](./CONTRIBUTING.md) first.\n\n## Author\n\n**Obscenity** © [Joe L.](https://github.com/jo3-l/) under the MIT license. Authored and maintained by Joe L.\n\n\u003e GitHub [@jo3-l](https://github.com/jo3-l)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjo3-l%2Fobscenity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjo3-l%2Fobscenity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjo3-l%2Fobscenity/lists"}