If you’re partial to a cup of coffee minus the caffeine, then next time you’ve boiled the kettle you should raise your mug in memory of Friedlieb Ferdinand Runge.

Runge was a 19th-Century German chemist who had come to the attention of Goethe – the poet and statesman who was also a keen science scholar. Goethe had heard of Runge’s groundbreaking investigation into belladonna, otherwise known as nightshade. Runge had isolated the compound that caused eye muscles to dilate if it was ingested.

Goethe had been recently given a case of coffee beans, and so he asked Runge to perform an analysis of the beans. What Runge discovered is arguably the most consumed drug in the modern world – caffeine.

You might also like:

Caffeine is present in other drinks and foods – notably tea and chocolate – but it is inextricably linked with coffee. It’s a stimulant and an appetite suppressant, a dependable pick-me-up for students cramming for exams, workers on nightshifts and anyone else needing a wake-up.

But caffeine has a darker side, too.

It can cause anxiety, insomnia, diarrhoea, excess sweating, racing heartbeat and muscle tremors. For many people, the pleasure of drinking coffee is outweighed by the caffeine-fuelled negatives.

Could caffeine be removed from coffee? The answer, as any supermarket aisle will tell you, is yes – but the process isn’t as simple as you might think.

The first person to hit upon a practical decaffeination method was another German, Ludwig Roselius, the head of the coffee company Kaffee HAG. Roselius discovered the secret to decaffeination by accident. In 1903, shipment of coffee had been swamped by seawater in transit – leaching out the caffeine but not the flavour. Roselius worked out an industrial method to repeat it, steaming the beans with various acids before using the solvent benzene to remove the caffeine. Decaffeinated coffee was born.

Benzene, it turned out, was a possible carcinogen, so the search was on for new techniques that could prise out the caffeine from the beans – and yet leave the flavour intact.

Chris Stemman, the executive director of the British Coffee Association, says most of those techniques from decaffeination’s earliest days are still being used today. But the process isn’t as straightforward as you’d expect.

“It isn’t done by the coffee companies themselves,” says Stemann. “There are specialist decaffeination companies that carry it out.” Many of these companies are based in Europe, Canada, the US and South America.

If you were to try and decaffeinate roasted coffee you’d end up making something that tastes a bit like straw – Chris Stemman

You might think that it would be easier to roast the coffee, grind it into the required powder (espresso, filter or instant) and then begin the decaffeination process. Not, so says Stemman.

“It takes place when the coffee is green, before roasting.

“If you were to try and decaffeinate roasted coffee you’d end up making something that tastes a bit like straw. So that’s why with 99.9% of decaffeinated coffee to this day, the process is done at the green coffee stage.”

There are several ways to decaffeinate coffee but the most prevalent is to soak them in a solvent – usually methylene chloride or ethyl acetate. Methylene chloride can be used as a paint stripper and a degreaser as well an agent to remove caffeine.

Ethyl acetate, meanwhile, is a natural fruit ether usually made from acetic acid – the building block of vinegar – and it’s also used to make nail polish remover (it has a distinctive sweet smell, much like pear drops).

The beans are first soaked in water and then covered in a solution containing either of these solvents. The caffeine is then drawn out by the solvent.

The solvent-laced water is then reused again and again until it is packed with coffee flavourings and compounds – pretty much identical to the beans, except for the caffeine and solvent. By this stage in the process the beans lose very little flavouring because they’re essentially soaked in a concentrated coffee essence.

Soaking coffee beans in solvents doesn’t sound like a particularly healthy enterprise, but both of these agents have got a clean bill of health. In 1985 the US’s Food and Drug Administration said the likelihood of any health risk from methylene chloride was so low “as to be essentially non-existent”. (FDA rules allow up to 10 parts per million of residual methylene, but coffee decaffeination usually uses solutions with one part per million).

Decaffeination became much more widespread as instant coffee became a staple

Two other methods use water. The Swiss Water method sees the beans soaked with water; the caffeine rich solution (full of flavours) is then strained though activated carbon which captures the caffeine. Starting in Switzerland in the 1930s, the process was first used commercially in 1979. It gained favour because it was the first decaffeination method not to use solvents.

There is another method, Stemman says, which involves the use of “super critical carbon dioxide”.  Beans that have been soaked in water are put in a stainless-steel extractor which is then sealed, and liquid CO2 blasted in at pressures of up to 1,000lbs per square inch. Like the Swiss Water method, it’s the C02 which binds with the caffeine molecules, drawing them out of the unroasted bean. The gas is then drawn off and the pressure is lowered, leaving the caffeine in a separate chamber.

It’s an ingenious method but it does have one big drawback, according to Stemman. “It can be enormously expensive.”

Decaffeination became much more widespread as instant coffee became a staple, says Stemman. But the early incarnations of instant decaff coffee were not a roaring success.

“If you look back 20 or 30 years ago, we [in the UK] really were a nation of instant coffee drinkers,” he says. “And the one thing that instant coffee didn’t really taste of was coffee. Decaff was even worse.”

Stemman says that as people have become more used to quality coffee – for instance, the UK now boasts some 24,000 coffee shops – this has forced coffee-making companies to find ways of enhancing flavour even in decaffeinated instant coffee.

“Decaffeination can be a complicated piece of chemistry, which is why there are these very sophisticated companies doing it.”

The centenary of decaffeination – 2006 – went by with little in the way of public fanfare. In the UK at least, the number of people stumping for a decaff coffee has fallen markedly even as the quality has improved – while as many as 15% of coffee drinkers chose decaffeinated brews in the 1980s, that’s fallen to about 8% today.

And does Stemman drink decaffeinated himself? “Generally, no, if I don’t want the caffeine, well I just won’t have a coffee or a tea.”

And there’s another thing. While each of these methods will take most of the caffeine away, there’s no such thing as a completely decaffeinated drink. If you really want to avoid any caffeine at all, it’s probably better to drink something that never had a trace of it in the first place.

--

Join 900,000+ Future fans by liking us on Facebook, or follow us on Twitter or Instagram.

If you liked this story, sign up for the weekly bbc.com features newsletter, called “If You Only Read 6 Things This Week”. A handpicked selection of stories from BBC Future, Culture, Capital, and Travel, delivered to your inbox every Friday.