Content moderator template
- Node.js
- Express
Mask profanity in comments, reviews and chat before they go live, and count what was caught.
A Node.js and Express app that cleans up user-generated text. Paste a comment, review or chat message and get it back with profanity masked, whether it was flagged, and how many words were caught. Use it by hand, or call its route when someone posts.

What it does
- Masks, doesn’t delete
- Replaces each offensive word with a mask character, so the rest of the comment still reads.
- Counts what it caught
- Returns how many words were masked, so you can hold heavy posts for review.
- Your choice of mask
- Use *, #, - or • for the masked letters.
- Keeps your key private
- The page calls your own server, which holds the key and limits each visitor to 10 checks a minute.
How it works
The route that masks a piece of text.
const MASKS = ['*', '#', '-', '•'];
// POST /api/moderate { text, mask }
app.post('/api/moderate', async (req, res) => {
const text = str(req.body.text, 5000);
const mask = MASKS.includes(req.body.mask) ? req.body.mask : '*';
if (!text) return res.status(400).json({ error: 'Enter some text to check.' });
try {
const data = await callApi('profanityfilter', { body: { text, mask } });
res.json({
success: true,
original: text,
filtered: data.filteredText,
isProfane: data.isProfane,
profaneWords: data.profaneWords || 0,
mask: data.mask
});
} catch (err) {
res.status(err.status || 502).json({ error: err.message });
}
});Deploy it
- Get a free API key
The free plan includes 200 credits a month, no card needed. Create your key.
- Deploy it
Click Deploy to Vercel. Vercel copies the repo to your GitHub account and asks for
APIVERVE_API_KEY: paste your key there. - Open your app
Vercel builds it and gives you a live URL, usually in about a minute. Every push to the repo redeploys it.
Try the Profanity Filter API — the call this template makes
No key required to try it. Get a key to use it in your app.
{
"status": "ok",
"error": null,
"data": {
"isProfane": true,
"filteredText": "Today is so **** hot! Why the **** would anyone go outside?",
"mask": "*",
"trimmed": false,
"profaneWords": 2
}
}