Express.js Profanity Filter
Drop in as Express middleware so every request body is screened before it hits your route handlers.
Quick start in Express.js
export async function moderate(req, res, next) {
const r = await fetch("https://api.theprofanityapi.com/v1/check", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.PROFANITY_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ text: req.body.text, context: "comment", mode: "balanced" }),
});
const { flagged } = await r.json();
if (flagged) return res.status(422).json({ error: "Content flagged" });
next();
}
app.post("/comments", moderate, (req, res) => { /* save */ }); Why context-aware matters
A plain word list flags "this game is sick" or medical text full of
anatomical terms. The Profanity API runs a five-layer pipeline that
scores intent, so "die" in a gaming taunt and "die" in a real
threat are handled differently. Pick a context and the engine
adjusts strictness automatically.
Other integrations
- Node.js
- TypeScript
- Python
- PHP
- Ruby
- Go
- Java
- C# / .NET
- Rust
- Kotlin
- Swift
- Dart
- Elixir
- Next.js
- NestJS
- Nuxt
- Fastify
- Django
- Flask
- FastAPI
- Laravel
- Symfony
- Ruby on Rails
- Spring Boot
- ASP.NET Core
- Phoenix
- React
- Vue
- SvelteKit
- Angular
- React Native
- Flutter
- WordPress
- Discord Bot
Ready to ship moderation?
Get an API key and 300 free requests a month. No credit card required.
Get started free →