Skip to main content
June 30, 2025
# Tags
Follow Us
Photo by Stephen Phillips – Hostreviews.co.uk

How To Build a Chrome Extension to Estimate the Carbon Footprint of Your Emails

June 30, 2025

Have you ever wondered about the carbon footprint of emails?

Calculating the actual value is impossible, as numerous factors are involved, including the energy used to write, send, receive, and store each email on one or more servers, as well as the embodied carbon of all the devices involved in the process.

However, several estimates have been attempted over the years. For example, Mike Berners-Lee counts the footprint to be between 0.03g and 26g of CO2 per single email (read more in this article from the Carbon Literacy Project).

In this tutorial, we’ll show you how to build a Google Chrome extension for Gmail that will generate a live score as users type their emails. The score will be 0-100 and will help users understand if the email they are going to send is “bad”, based on a few simple factors:

  • The size in bytes of the email’s body
  • the size in bytes of the email’s attachments
  • the number of recipients (who will each receive a copy of the original email and attachments being sent)

What You’ll Build

  • A floating badge that shows a real-time carbon score while composing emails in Gmail.
  • A breakdown panel with scores based on:
    • Email body size
    • Number of recipients
    • Attachment size
  • A draggable UI that remembers position across sessions.
  • A Chrome Web Store–ready extension package.

You can see the finished product on the Chrome Web Store.

1) Set Up The Project

Create a folder for the Chrome extension, e.g. gmail-carbon-score, with these files (or clone our GitHub Repository):

  • manifest.json
  • content.js
  • icon.png
  • style.css (optional)

2) Complete the Manifest File

Edit manifest.json (Chrome Extension Manifest V3):

{
  "manifest_version": 3,
  "name": "Gmail Carbon Score",
  "version": "1.0",
  "description": "Estimate the carbon footprint of your emails while composing in Gmail.",
  "permissions": [],
  "host_permissions": ["https://mail.google.com/*"],
  "content_scripts": [{
    "matches": ["https://mail.google.com/*"],
    "js": ["content.js"],
    "run_at": "document_idle"
  }],
  "icons": {
    "128": "icon.png"
  }
}

3) Add the Content Script

content.js contains all of the extension’s logic:

  • it observes when the Gmail compose window opens
  • It monitors body size, recipients, and attachments
  • It injects a draggable badge onto the web page
  • It calculates and displays the live score

You can get the full version from our GitHub Repository; it’s too long to paste here in full, but it includes:

  • MutationObservers for compose detection
  • computeScore() for the main score logic
  • getRecipientCount() and getAttachmentSizeMb() functions
  • Persistent localStorage for UI position

4) Test Locally

Once you have everything set up:
  1. Open Chrome → go to chrome://extensions/
  2. Enable Developer Mode
  3. Click “Load unpacked” and select your gmail-carbon-score/ folder
  4. Open Gmail → Click Compose
  5. Watch your carbon score update live!
A dynamic carbon badge appears at the bottom of your email.

5) Create a Chrome Web Store Developer Account

In order to publish your Chrome Extension you need a developer account.
  1. Visit: chromewebstore.google.com
  2. Sign in with your Google account
  3. Pay the one-time developer registration fee
  4. Go to the Developer Dashboard

6) Prepare Your Extension for Upload

Create a Zip file containing your extension files. On Mac OS, open Terminal and run:

cd gmail-carbon-score/
zip -r -X ../carbon-score.zip . -x "*.DS_Store"

⚠️ This avoids macOS hidden files like __MACOSX that break validation.

Confirm that manifest.json is at the root of the zip.

7) Submit to the Chrome Web Store

  1. In the Developer Dashboard → click “New Item
  2. Upload your ZIP file
  3. Fill in:
    • Title
    • Short description
    • Full description (include features & benefits)
    • Category: Productivity
    • At least one 1280×800 screenshot
    • Icon: 128×128 PNG

Permissions Justification:

Google require that you give a justifications for the permissions that your extension needs.

host_permissions: Access Gmail’s compose window to detect email body size, recipients, and attachments. No personal data is collected or transmitted.

8) Publish and Share

Once your extension is reviewed (usually within 1–3 days), it will be live in the Chrome Web Store. Promote it on:

  • LinkedIn
  • Developer forums
  • Climate-tech communities
  • Your company newsletter

Why It Matters

Every byte of email impacts global energy consumption. This extension provides users with immediate feedback and motivation to send lighter, more efficient messages, triggering a ripple effect that promotes sustainable digital habits.

Have an idea for a digital product?

Are you thinking about creating a software platform or mobile application? We’re here to share our insights and experiences from the front lines of app development. Drop us a message to discover how we can help turn your vision into reality!