Coffee, on its surface, is an incredibly simple beverage: just add hot water to ground up roasted beans. However — as in any great pursuit — achieving perfection remains elusive.

In the quest for the flawless cup of coffee, aficionados have looked at everything from roasting technique, to method of grinding, to the perfect ratio of water to coffee (said to be 17.42 units of water to 1 unit of coffee).

But less often considered is the water itself. While we tend to view tap water as a pure ingredient, it’s actually loaded with minerals that can influence coffee’s flavor. And now chemists have pinned down how the chemicals in different types of water interact with coffee beans to shape the taste of the brew that results.

Science to the Rescue

Coffee is loaded with a tremendous amount of natural chemicals and over 1,000 aroma compounds. Water, on the other hand, can be rich in minerals like calcium and magnesium if it’s “hard,” or if it’s “soft,” rich in sodium — used by water softeners to remove impurities.

For this study, Christopher Hendon, a chemist from the University of Bath, focused on the way different kinds of water affect the extraction of six chemicals that contribute to the flavor of coffee. These flavors included citric acid, lactic acid and eugenol — responsible for coffee’s “woodsy” taste. He found that magnesium in hard water, for example, sticks to eugenol, giving the resulting brew an even woodsier taste, Business Insider reports. And bicarbonates in hard water will make the coffee bitterer. The findings were published last month in the Journal of Agricultural and Food Chemistry.

“Hard water is generally considered to be bad for coffee, but we found it was the type of hardness that mattered – while high bicarbonate levels are bad, high magnesium ion levels increase the extraction of coffee into water and improve the taste,” Hendon told Phys.org.

Selecting the Right Coffee

Soft water, unfortunately, lacks the sticky minerals of hard water, so it’s poorer at extracting flavorful compounds. But if you live in a soft-water haven, don’t dismay: a tactical selection of beans may help counter the problem.

Just like one would pair wine with a certain type of food, the same is true for your type of water and the coffee you brew. You can get a rough idea about the hardness of your water by checking out the U.S. Geologic Survey water map. Then, purchase beans that are best brewed with hard or soft water, which a knowledgeable roaster should know.

Photo credit: Patrick T. Power/Shutterstock