All posts

I built an iced coffee calculator to stop doing math by the kettle

A 1950s-style illustration of an iced coffee setup, a calculator on a phone, and an ice cube mascot

I’ve been enjoying James Hoffmann’s iced-coffee technique with the Hario Switch. With the valve closed, the coffee steeps; opening it drains the brew onto ice. Since that ice counts toward the total water, changing the batch size means recalculating the coffee, hot water, and ice beside the kettle and scale. It’s easy arithmetic, but I was tired of doing it every time.

I also like the Clever Dripper, which suits the same immersion approach. I wanted to choose a brewer, adjust the batch size and ice split, and get the amounts immediately. That became the Iced Coffee Calculator. The math took a few lines; most of the work went into scaling six recipes while respecting their different timing, followed by more effort than expected to keep mascot artwork off the buttons.

The recipe math

The default recipe uses 500 mL of total water, a 1:13.3 ratio, and 34% ice. That gives me 37.5 g coffee, 330 mL hot water, and 170 g ice:

coffee = total water / ratio
ice = total water * ice percentage
hot water = total water - ice

For kitchen purposes, I treat 1 mL of water as roughly 1 g. Coffee rounds to the nearest half gram and ice to a whole gram. An early version rounded ice and hot water independently, which sometimes left them adding up to the wrong total. Now I round the ice first and subtract it from the total to get the hot water.

A test checks that those amounts add up for every whole-milliliter batch from 150 to 1,500 mL and every ice percentage from 20% to 50%. That’s 41,881 combinations, which is more iced coffee than I plan to make personally.

Six recipes, with their own timers

The first version used Hoffmann’s iced immersion method for the Hario Switch and Clever Dripper. Once that worked, I started looking at other published recipes.

Counter Culture’s flash brew puts ice in the carafe, then uses a bloom and pulse pours. April’s high-ice recipe uses equal amounts of hot water and ice, while Kurasu’s Japanese iced V60 uses a 1:13.75 total-water ratio and three distinct pours. Lance Hedrick’s low-ice technique waits until brewing is finished to add ice, and AeroPress’s Japanese-style recipe includes a press stage.

Together with Hoffmann’s immersion recipe, those made six useful starting points with substantial differences. April uses 50% ice; Lance uses 20%. Kurasu’s ratio displays as 1:13.8 because the interface adjusts in tenths, but kitchen rounding still reproduces its source batch: 16 g coffee, 150 mL hot water, and 70 g ice. I left out cold brew, Vietnamese iced coffee, and shakerato for now. Concentrate dilution, milk, syrup, and overnight brewing would require a different calculator.

The recipes also exposed a flaw in the timer. I’d attached it to the broad brewing method, so every flash-brew recipe inherited roughly the same sequence. That worked for one recipe but couldn’t represent several: Kurasu needs three timed pours with cumulative targets, Counter Culture ties its bloom to the coffee dose and later pours to hot-water volume, and Hoffmann’s immersion time depends on the roast selection. Lance’s timer switches from counting down to counting up at 1:45 for the final pour, drawdown, and chilling, with ice added at the end.

Each recipe now defines its setup, duration, cues, quantity targets, release stage, and finishing instructions. Targets can be fractions of the hot water or ice, or multiples of the coffee dose. A simplified Kurasu profile looks like this:

{
  duration: fixed(130),
  steps: [
    { at: elapsed(0), target: hotWaterFraction(40 / 150) },
    { at: elapsed(40), target: hotWaterFraction(100 / 150) },
    { at: elapsed(70), target: hotWaterFraction(1) }
  ]
}

Doubling that batch changes the 40, 100, and 150 mL targets to 80, 200, and 300 mL. The original cue times remain guidance, since a larger brew won’t necessarily draw down at the same rate.

The timer derives elapsed time from the start time, pause duration, and current time. A short interval refreshes the display, but the clock doesn’t depend on counting those refreshes, so a slow background tab won’t make it drift. It supports pause and resume, optional sound and vibration, and a screen wake lock where the browser allows it. After a recipe’s fixed stages, drawdown and pressing count upward to accommodate differences in brewer, grind, and coffee.

A 1950s-style ratio machine turning water, coffee, and ice into measured outputs and a timed recipe

An imaginary machine showing how recipe inputs become brew amounts and scaled timer instructions.

The comic strip

I wanted something more playful than a tasteful beige coffee app. The design borrows from 1950s appliance advertisements: refrigerator aqua, mustard yellow, cherry red, heavy black outlines, halftone dots, and printed-looking shadows. Of the early mockups, I liked the second direction best because its Pick, Tune, Brew sections felt like one connected comic strip. They stack on a phone and read across on a wide screen.

The finished Iced Coffee Calculator showing its connected Pick, Tune, and Brew panels

The finished interface uses standard browser fields and buttons inside the comic framing.

The working title was Ratio Hero, which I didn’t like. Iced Coffee Calculator is less clever and tells you what it does. I did like the ice cube mascot and asked for more of it, then found we’d put the same character on screen twice. The final version keeps the ice cube in the masthead, with a coffee bean and an iced-coffee glass near the brew button and timer.

The characters are generated artwork. Controls and numbers stay in HTML and CSS so they’re crisp, selectable, and accessible; generated art doesn’t have to carry interface text.

What needed fixing in the browser

I built this with Codex, an AI coding agent, which made visual experiments and changes to the data model fast. Each result still needed a browser check, especially at phone widths. The mascot overlapped Start Timer on desktop, for example. After we fixed that, a phone-width screenshot showed it covering the button again.

The recipe selector had a Custom option that changed as I edited values, confusing the recipe I’d started with and the adjustments I’d made. It now keeps the selected recipe stable and shows an Adjusted badge with a Reset action when I change the ratio or ice split.

The browser also added spinner arrows to inputs that already had large plus and minus buttons. I removed the redundant arrows. Centering needed more care: 1:13.3 and 500 mL looked off because their prefixes and units had different widths, even though their layout boxes were centered. An invisible mirrored value now sizes the editable number, letting us center the whole prefix-value-unit group. These were small fixes, but I noticed the defects every time I used the calculator.

A static app

The app uses React, TypeScript, and Vite and runs as a static progressive web app on GitHub Pages, with no account, database, application server, or API. React handles the screen; plain TypeScript functions handle the coffee math and brewer rules. Timer profiles are data, and one function combines a recipe with the calculated amounts to produce its instructions. Most of the code is ordinary React, with the coffee-specific behavior in the recipe model.

Settings live in local storage under a versioned key. The app can read settings from the old Ratio Hero version, and if storage is blocked or full, it still works but starts fresh next time. A service worker caches the app shell, code, artwork, and bundled fonts, so losing the connection after the first visit won’t interrupt a brew.

Pushes to the main branch run the tests and production build before GitHub Actions deploys the static files. The suite has 30 tests covering brew math, timer behavior, source-batch reproduction, and profile validation.

The finished calculator supports the Hario Switch 02 and 03, Clever Dripper, NextLevel Pulsar, Hario V60 02, April Brewer, and AeroPress with the Flow Control cap, paired with the recipes that fit them. It warns when an immersion brewer can’t hold the selected hot-water dose and can scale the batch down to fit.

You can try the Iced Coffee Calculator or look through the source on GitHub. The default is still Hoffmann iced immersion with the Hario Switch. I choose a batch size, adjust the ice, and leave the arithmetic to the calculator while I make the coffee.