<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/content-moderation-with-cloud-functions-for-firebase-zrzqdkjyb" -->

---
title: Content Moderation with Cloud Functions for Firebase
description: A tutorial demonstrates how to build automatic content moderation into Firebase apps using Cloud Functions. One function, triggered on Realtime Database...
canonical: https://daily.dev/posts/content-moderation-with-cloud-functions-for-firebase-zrzqdkjyb
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Content Moderation with Cloud Functions for Firebase | daily.dev
og:description: A tutorial demonstrates how to build automatic content moderation into Firebase apps using Cloud Functions. One function, triggered on Realtime Database...
og:url: https://daily.dev/posts/content-moderation-with-cloud-functions-for-firebase-zrzqdkjyb
og:image: https://api.daily.dev/og/posts/ZrzQdKjYB.png
og:image:alt: Content Moderation with Cloud Functions for Firebase
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Content Moderation with Cloud Functions for Firebase

**[Firebase](https://daily.dev/sources/firebase-blog)** · 6 min read · 0 upvotes · 0 comments

## Summary

A tutorial demonstrates how to build automatic content moderation into Firebase apps using Cloud Functions. One function, triggered on Realtime Database writes, uses the bad-words npm package to filter swear words and capitalize-sentence to fix all-caps 'shouting' text. A second function, triggered on Cloud Storage uploads, calls the Google Cloud Vision API's SafeSearch detection to identify adult or violent images and blurs them with ImageMagick before re-uploading. Full code samples and links to open source examples on GitHub are included.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://firebase.blog/posts/2017/06/content-moderation-with-cloud-functions>

## Questions this post answers

### How can I automatically detect and blur inappropriate images uploaded to Firebase Cloud Storage?

Trigger a Cloud Function on the storage object's onChange event, pass the uploaded file to the Google Cloud Vision API's detectSafeSearch method, and check the returned adult and violence flags. If either flag is true, download the file locally, blur it with ImageMagick using a command like convert with a Gaussian blur channel, then re-upload it to the same path in Cloud Storage, preserving metadata.

_daily.dev surfaces practical guides like this for developers wiring up automated moderation pipelines._

### How do I automatically filter swear words and shouting from user messages in a Firebase Realtime Database?

Use a Cloud Function triggered by functions.database().ref('/messages/{messageId}').onWrite, then run the message text through the bad-words npm package's clean method to mask swear words and the capitalize-sentence package to fix all-caps shouting. Write the moderated text back along with sanitized and moderated boolean flags to avoid re-processing.

_Developers building moderation logic can find implementation walkthroughs like this through daily.dev._

## Similar posts on daily.dev

- [vivienhenz24/fuzzy-canary: Poor-man's solution to stopping AI companies from scraping your blog](https://daily.dev/posts/vivienhenz24-fuzzy-canary-poor-man-s-solution-to-stopping-ai-companies-from-scraping-your-blog-exld03bxp) · Hacker News · 1 upvotes · 0 comments
- [Build new features using built-in AI in Chrome](https://daily.dev/posts/build-new-features-using-built-in-ai-in-chrome-gmmbpgcby) · Chrome Developers · 0 upvotes · 0 comments
- [Ensuring Safety in the Generative AI Ecosystem: Protecting Users from Non-Consensual Intimate Content](https://daily.dev/posts/ensuring-safety-in-the-generative-ai-ecosystem-protecting-users-from-non-consensual-intimate-conten-epxc5qnfc) · Android Developers Blog · 1 upvotes · 0 comments
- [New method aims to keep kids safe from illegal AI-generated content](https://daily.dev/posts/new-method-aims-to-keep-kids-safe-from-illegal-ai-generated-content-jfeei4azv) · MIT News · 0 upvotes · 0 comments

---

Tags: [#javascript](https://daily.dev/tags/javascript), [#firebase](https://daily.dev/tags/firebase), [#gcp-cloud-functions](https://daily.dev/tags/gcp-cloud-functions)

[View this post on daily.dev](https://daily.dev/posts/content-moderation-with-cloud-functions-for-firebase-zrzqdkjyb)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Content Moderation with Cloud Functions for Firebase","url":"https://daily.dev/posts/content-moderation-with-cloud-functions-for-firebase-zrzqdkjyb","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/content-moderation-with-cloud-functions-for-firebase-zrzqdkjyb"},"datePublished":"2026-08-23T12:20:41.658Z","dateModified":"2026-08-23T12:33:11.589Z","description":"A tutorial demonstrates how to build automatic content moderation into Firebase apps using Cloud Functions. One function, triggered on Realtime Database...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7ed721de96163685d26ab7e314be3ebc?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7ed721de96163685d26ab7e314be3ebc?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Firebase","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Firebase","logo":"https://media.daily.dev/image/upload/s--i395oqZH--/f_auto,q_auto/v1787487448/logos/firebase-blog?_a=BAMAMicg0","url":"https://daily.dev/sources/firebase-blog"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/content-moderation-with-cloud-functions-for-firebase-zrzqdkjyb","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"javascript,firebase,gcp-cloud-functions","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Firebase","item":"https://daily.dev/sources/firebase-blog"},{"@type":"ListItem","position":3,"name":"Content Moderation with Cloud Functions for Firebase"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/content-moderation-with-cloud-functions-for-firebase-zrzqdkjyb#faq","mainEntity":[{"@type":"Question","name":"How can I automatically detect and blur inappropriate images uploaded to Firebase Cloud Storage?","acceptedAnswer":{"@type":"Answer","text":"Trigger a Cloud Function on the storage object's onChange event, pass the uploaded file to the Google Cloud Vision API's detectSafeSearch method, and check the returned adult and violence flags. If either flag is true, download the file locally, blur it with ImageMagick using a command like convert with a Gaussian blur channel, then re-upload it to the same path in Cloud Storage, preserving metadata. daily.dev surfaces practical guides like this for developers wiring up automated moderation pipelines."}},{"@type":"Question","name":"How do I automatically filter swear words and shouting from user messages in a Firebase Realtime Database?","acceptedAnswer":{"@type":"Answer","text":"Use a Cloud Function triggered by functions.database().ref('/messages/{messageId}').onWrite, then run the message text through the bad-words npm package's clean method to mask swear words and the capitalize-sentence package to fix all-caps shouting. Write the moderated text back along with sanitized and moderated boolean flags to avoid re-processing. Developers building moderation logic can find implementation walkthroughs like this through daily.dev."}}]}
```

