CarbonTrace

Getting started with CarbonTrace

CarbonTrace is in early access. Parts of it work today and parts are still rough, and this page tells you which is which.

The code isn't public yet. To hear when CarbonTrace opens up, join the waitlist.

What it does on a website

  1. You add a small script to your site

    It's two short tags at the top of each page. One loads the script. The other tells it where your CarbonTrace server is and which project the page belongs to.

  2. It notices how heavy each page is

    Each time someone opens a page, the script adds up the size of the files that page loaded. It can't see them all: files your browser had already saved, and most files from other sites, count as nothing. It sends the total to your CarbonTrace server with your project's key, plus a region if you set one. No cookie goes with it, and it doesn't say which page it was.

  3. The numbers show up on your dashboard

    The server turns the size into grams of CO2e, which counts carbon dioxide and the other gases that warm the planet. Your dashboard adds the grams up and shows them as cups of tea and months of a tree's growth.

It can count two more things from your server's own code: one program asking another for data (an API call), and questions sent to an AI. How it works shows the sums.

Early access: what works today

You can't sign up and start yet. Today CarbonTrace is code that a developer sets up on a server you run.

Works now

  • Estimates for web pages, API calls and AI prompts
  • A dashboard with your totals, a chart for each day and tips on where to cut
  • Saving your data: the server keeps it in a file, so it's still there after a restart

Not yet

  • A version I host for you: you run the server yourself
  • A ready-made script for websites: a developer builds it from the code first
  • Public code: I haven't opened it up yet

What setting it up takes today

For developers: these are the steps once you have the code. You need Node.js 22.9 or newer. I ran each command on a fresh copy before I put it here.

Install it, copy the example settings and start the server. The example settings hold two test keys, so one project is ready to use.

npm install
cp .env.example .env
npm run server

In a second terminal, start the dashboard. It prints its address. Open that and paste the secret test key.

npm run dev

Then build the script for your site. Your site has to serve that file itself, because the CarbonTrace server doesn't.

npx esbuild sdk/client.ts --bundle --minify --outfile=public/carbon-trace.min.js

Swap the test keys for your own before other people can reach the server. The publishable one goes in your site's pages. Keep the secret one out of them: it can read your dashboard and erase your data.

Hear when it opens

Leave your email and I'll write once, when CarbonTrace opens up. I won't use it for anything else. I delete it after 12 months. The privacy page says what I keep and how to come off the list.