React Profanity Filter

Validate user input in React by calling a moderation route on your own backend that holds the key.

Quick start in React

async function checkText(text) {
  const res = await fetch("/api/moderate", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ text }),
  });
  const { flagged } = await res.json();
  return flagged;
}

// in a component
const handleSubmit = async () => {
  if (await checkText(value)) setError("Please revise your message.");
  else submit(value);
};

Note: Never put your API key in client code. Proxy through a backend route (see the Next.js / Express examples).

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

Ready to ship moderation?

Get an API key and 300 free requests a month. No credit card required.

Get started free →