Inspiration

An NGO monitoring and evaluation officer explained to us that aid groups routinely gather household survey data on KoboToolbox and ODK and export it to Excel or CSV. What often happens in practice: "we send the raw data file in Excel", and it happens "more often than what our data protection policy says it should." Government counterparts request the raw data "just to double check the numbers," and partners can click the Kobo export button themselves. Data cleaning is done by hand: staff remove the name, phone and household ID columns. One colleague has a GPS-rounding script, but it is only on her laptop and not shared.

In reality this leaves a lot of unprotected data in between:

  • free text fields like "beneficiary not home, will come back tomorrow, contact Fatima at 07…";
  • GPS that has only been rounded, because rounded coordinates plus the village name plus household size can be enough to identify someone;
  • forgotten metadata, such as when a form was submitted, by whom, and on which device;
  • photo folders that haven't been reviewed.

Staff are also improvising when it comes to AI. As the officer put it: "We have seen many people pasting multiple rows of comments to generate a summary in order to use them in narrative reports … people don't know of other tools that do it in a secure way." And: "if you can make a tool that detects phone numbers, names and coordinates in free text columns and before it's sent, we will definitely be using it here." We made Kobo Export Guard to do exactly this.

What it does

It opens a Kobo/ODK CSV export in the browser and never uploads it. Code, not AI, proposes an action for each column:

  • drop Kobo metadata and directly identifying data;
  • round GPS to 2 decimal places (≈1.1 km) and blank the altitude and precision;
  • scan the free-text fields;
  • keep what remains.

Every decision is shown with its reason, and the person can change any of them. The free-text scanner finds phone numbers, emails and GPS coordinates with code, and names and places with Gemini Nano running in Chrome on the user's own computer.

The review page shows all the masking, puts potentially sensitive entries at the top, and allows removing any comment. It also flags cases where fewer than 5 rows share the same combination of attributes, such as village + household size. The app exports a cleaned CSV and a receipt listing what it removed, what is still at risk, and every Google AI request the page made. A counter at the top shows every request the page sends to Google AI endpoints.

For narrative reports there is an optional summary of the cleaned comments: a secure way to summarise data instead of pasting rows into a chatbot. After consent and a final code check, Gemini Nano writes it on the device when it can; otherwise the cleaned text goes to Gemini in the cloud. The page shows where it ran and why.

How we built it

We built it on the Firebase AI Logic web SDK with hybrid inference, and we route by how sensitive the text is:

  • Raw comments: ONLY_ON_DEVICE, never a fallback. If Gemini Nano isn't there, the app refuses.
  • Cleaned comments: PREFER_ON_DEVICE, a true hybrid call. Gemini Nano writes the summary when it is ready and the text fits. Otherwise it goes to Gemini in the cloud. The text is already cleaned, so falling back is safe. "Fits" comes from a measurement: Nano's context window on our laptop is 9,216 units, and 3,200 characters of comments used 726, so above 30,000 characters the summary goes straight to the cloud.

We hit a known problem in firebase 13.4.0 (firebase-js-sdk#10635). If the browser has no LanguageModel at all, the SDK still sends the request to the cloud, even with InferenceMode.ONLY_ON_DEVICE, and initializeDeviceModel() does not throw an error. The SDK's mode setting alone does not stop this. So before each on-device request, the app checks LanguageModel.availability() itself and refuses unless it is "available". After the request it also checks inferenceSource.

Every path that can reach the cloud is locked down with Firebase products. We tested each one:

  • App Check (reCAPTCHA Enterprise / Fraud Defense) is enforced, so any request without a token receives a 401. AI Logic uses limited-use tokens with replay protection enforced: each cloud request gets a fresh token.
  • Authentication: the app signs in anonymously before any cloud call, and AI Logic's authenticated-users mode is enforced. A call without sign-in gets a 401; the person still needs no account.
  • Remote Config holds a cloud_enabled kill switch. When it is off, or when the config cannot load, nothing can be sent. It also holds the cloud model's name (gemini-3.5-flash-lite) and one fallback (gemini-3.5-flash), tried once on a server error.
  • AI monitoring tracks latency, errors and token use. By default it stores the actual prompts and responses in Cloud Logging, so we added a logging exclusion: they are not stored.
  • Hosting serves the app and the judge page.

The app is written in TypeScript, built with Vite and tested with Vitest (18 tests), and it uses PapaParse to read the CSV.

Challenges we ran into

We measured each of these:

  • On one synthetic lab-report photo, Nano misread the table and shifted rows in both runs, so it hid a nitrate value of 62 when the limit is 50. This is why photos are out of scope.
  • Nano detected a name in one run and missed it in another. We added a code safety net that masks a capitalised word after "call", "with", "Mr" and similar words. We also added a consistency pass: if something is masked in one row, it is masked in every row.
  • Common words came back as names or places in our test runs ("well", "river", "Jerrycans", "husband"), so we added a stoplist in code.
  • While we recorded the demo, the cloud summary failed in 3 of 5 takes ("busy" on both models twice, and one timeout). So we set the model name in Remote Config and added one fallback.
  • The first on-device summary invented a number ("reported 12 times"; the true count was 4). The prompt now forbids numbers, and later runs had none. Counts belong in code, not in a small model's prose.
  • When we enforced authenticated-users mode, even our own signed-in calls got a 401. The AI Logic SDK looks for Firebase Auth only once, when getAI() runs; we had set up Auth later. Setting up Auth before getAI() fixed it.

Accomplishments that we're proud of

  • On a 40-row synthetic export, 37 comments were read on the device at about 9 seconds each, with 0 requests to the cloud during the scan. All 25 names and every phone number in the sample were masked.
  • In a browser without the built-in model, the app sends nothing, and the code-only cleaning still works. In a real Firefox browser, the app showed "No built-in model in this browser", turned the name scan off, and sent 0 requests.
  • The summary runs on both sides and shows where it ran: on the device with Gemini Nano (0 requests, about a minute), in the cloud in a browser without Nano (1 request, 5.5 s), and in the cloud when the text is too long for the device (1 request, 3.1 s).
  • A real practitioner described the problem, and the tool answers their request directly.

What we learned

"On-device" is a privacy promise only if the app checks that the model is really there. The mode name in the SDK is not enough.

What's next for Kobo Export Guard

We'll test it with actual anonymised comments in Somali, Hausa, Igbo and Pidgin; so far we've only tested in English. We also plan:

  • XLSX import and Kobo API integration;
  • photo and media review;
  • a pilot with the NGO team that explained the problem to us.

We'll be honest about the limitations:

  • Name detection only works on desktop Chrome with Gemini Nano.
  • The app hasn't been used in a real deployment yet.
  • The demo data is synthetic.

Built With

  • chrome
  • firebase-ai-logic
  • firebase-app-check
  • firebase-hosting
  • firebase-remote-config
  • gemini
  • gemini-nano
  • papaparse
  • vite
  • vitest
Share this project:

Updates

posted an update —

Final build is in.

  • New demo video (2:26), with my own voice: https://youtu.be/I1m7qC1HoUI
  • Captions now sit in their own band under the picture, so they cover nothing on screen.
  • The summary of cleaned comments is now a real hybrid call (PREFER_ON_DEVICE): Gemini Nano writes it on the device when the text fits. A browser without Nano, or an export too long for the device, sends the already-cleaned text to Gemini in the cloud. The page shows where it ran.
  • The no-LanguageModel cloud fallback we guard against is a known SDK issue: firebase-js-sdk#10635. The app checks LanguageModel.availability() before every on-device call and refuses otherwise.

Try it: https://buildhybridai-daniel.web.app/judge (3 minutes, no account, synthetic data) Code: https://github.com/dannwaneri/kobo-export-guard

Submission history