As a chemistry teacher, I’m inevitably fascinated by chemistry in general, but especially by the chemistry we come across on a daily basis. Rather than only sharing this with my students, I started a website, Compound Interest, where I create illustrated explanations of chemical concepts for anyone who’s interested to gain a better insight into the chemistry that pervades our lives.

So what can chemistry do for you? Well, for starters, it can help you make a better cup of coffee.

Any coffee connoisseur will tell you that good coffee should never taste bitter. However, in the less-than-ideal coffee world that the majority of us inhabit, bad, bitter-tasting coffee is much more common than we’d like. Luckily, there are plenty of tips out there on how to improve this, including the odd-sounding suggestions that adding a pinch of salt to coffee can improve the flavour. Science can help us explain how these suggestions might work – and how to make the perfect cup of coffee.

What makes coffee taste bitter?

Surprisingly, we still don’t know exactly what it is that makes some coffee taste bitter. Although the caffeine that’s present has a mildly bitter taste, it isn’t the main bitter component. Compounds called chlorogenic acid lactones and phenylindanes are thought to contribute; the former are in high levels in light- to medium-roast coffee, whereas the latter are found in darker roasts, and have a harsher taste.

Does adding salt to coffee temper bitterness?

Adding a pinch of salt might seem an unusual way to counter bitterness, but the science checks out. Researchers back in 1997 put it to the test by mixing salt into solutions of a bitter-tasting chemical and getting subjects to judge the bitterness. The volunteers consistently rated the solutions containing salt as being less bitter, despite the fact that the concentration of the bitter chemical in both solutions was identical.

The coffee-water balance

Remedying bad coffee-making with salt is a solution of sorts, but it’s better to tackle the problem closer to the cause. Extraction is a precise chemical process that can be tweaked in order to improve the flavour of your coffee. One important aspect is the ratio of coffee to water during the brewing process. Around 60g of coffee to a litre of water is recommended; in slightly more useful terms, that works out as a single gram of coffee for every 16ml of water, or around 7g for a single espresso shot.

The coffee-water balance is important because too much coffee can lead to greater extraction of bitter compounds, as the water is in contact with the coffee for longer. On the other hand, too much water will lead to a dilute, weak-tasting coffee.

Photograph: Edmund D. Fountain/ZUMA Press/Corbis

Brewing time and bitterness

Brewing time is another important factor. At a simple level, there are three stages of compounds extracted from coffee. Acidic, fruity-flavoured compounds are the first to be extracted, followed by more earthy, caramel-like compounds, and finally the bitter-tasting compounds. Short brew times lead to only the first group of compounds being extracted, whereas over-brewing can lead to an excess of the bitter, astringent flavours.

For the best coffee, we have to aim between these two extremes. Different coffees come with different recommendations. For an espresso coffee, the water should only be in contact with the coffee for 20-30 seconds; in a plunger pot, this increases to 2-4 minutes.

Temperature and bitterness

Water temperature also affects the bitterness. The ideal temperature is between 91-96˚C – higher than this, and you’re likely to burn the coffee, increasing the concentration of astringent compounds. Lower temperatures lead to poor overall extraction of compounds from the coffee. Conversely, the much lower temperature of cold-brew coffee does lead to lower dissolved levels of the compounds causing bitterness, though it comes with the trade-off of a much-elongated brewing time.

Type of coffee and grinding

Even the best extraction technique in the world can be thwarted by poor-quality coffee. There are two primary types, arabica and robusta, with arabica widely considered to have the finer flavour. Robusta coffee contains higher concentrations of phenols, pyrroles, and sulfur compounds, leading to a flavour unflatteringly described as harsh and rubbery.

The size of the particles in your coffee grounds can also help or hinder. Too large, and the compounds will be extracted ineffectively, leading to weak-tasting coffee. Too fine, and the compounds, including the bitter-tasting ones, will be extracted too quickly. Again, it’s the case of finding that perfect balance.

Milk, sugar and coffee

If the honing of your extraction method fails miserably, you can always remedy your bitter coffee in a more traditional manner. Milk simply masks the taste, but it also contains the sugar lactose which can impart a degree of sweetness. Sugar, on the other hand, causes caffeine molecules to clump together, which along with its taste-masking ability helps to reduce the perception of bitterness.

It’s clear that a good cup of coffee is harder to create than you might have expected. Still, there are bound to be times when the quality of the coffee isn’t of primary importance – I know that, as a teacher, starting the day at six in the morning, I’m more concerned with getting the caffeine hit than I am with the finer points of coffee flavour. Nonetheless, equipped with the knowledge of the science behind the extraction process, a better morning coffee is within your grasp.