Switching to a healthier diet could extend your life by more than a decade, research suggests.
Experts say eating more whole grains, legumes and nuts while avoiding red and processed meat is the best way to increase life expectancy.
The research in Norway looked at the typical Western diet that the average Brit is likely to eat every day.
It contains hardly any nuts or legumes, too few fruits and vegetables, half a liter of sugary drinks and 50 percent too much dairy products.
A 20-year-old Brit or American who follows the researchers' optimal diet could live 13 years longer than someone who doesn't, the study calculated.
But even changing your diet later could still significantly extend your lifespan, even in your 80s.
Legumes, whole grain products and nuts lower cholesterol levels and are full of vitamins and minerals.
The Western diet typically contains a large amount of processed foods high in salt and sugar, as well as more red meat and dairy products.
A plethora of studies have linked diet to life expectancy, primarily through obesity, the condition related to cardiovascular disease, diabetes and various cancers.
Around a quarter of adults in the UK and almost half of adults in the US are classified as obese.
This graphic shows the impact of increasing or decreasing the amount of certain food groups in your diet on your life expectancy. The largest increases came from eating more legumes such as lentils, whole grains and nuts, and reducing red and processed meat consumption. The earlier people started making these changes, the greater the impact on their lifespan, but the authors emphasized that significant improvements could still be made if people started eating healthier in their 60s and 80s
A diet high in legumes, a family of vegetables such as chickpeas, lentils and beans that are high in protein, fiber, vitamins and minerals but very low in fat, has been linked to over two years longer life expectancy
Researchers at the University of Bergen said a 60-year-old could still extend his lifespan by about eight and a half years by sticking to his optimal diet.
For 80-year-olds, dietary changes could extend their expected life expectancy by three and a half years.
The study, published in the journal PLOS medicine collapsed how many more years people could live by eating more or less of each food group.
They did this by comparing typical European and American diets to what they called optimal diets for health and running them through a computer simulation that examined health risks by age and food consumption.
The largest single increase came from eating more legumes such as lentils, a family of vegetables that includes chickpeas, lentils and beans.
If a 20-year-old increased his intake from the typical 0g per day of legumes to 200g per day - the equivalent of a large bowl of lentil soup - he could expect to live almost two and a half years longer, the researchers said.
Legumes are naturally low in fat but rich in fiber, protein, vitamins and minerals.
Other large increases in life expectancy came from eating 225g of whole grains per day, such as porridge and brown rice, as well as a daily serving of 25g of nuts. Each of these was associated with two additional years of life.
As for what to avoid, researchers said that completely eliminating red and processed meats, which are typically higher in fat and salt, from your diet could add about four years to your lifespan overall.
Interestingly, all dietary changes had a greater impact on men's estimated life expectancy than women's, although the researchers did not theorize why this was the case.
The study's lead author, nutrition expert Professor Lars Fadnes, said providing a quick and easy calculator could help people make better dietary decisions.
“Understanding the relative health potential of different food groups could enable people to make viable and significant health progress,” he said.
,The Food4HealthyLife calculator could be a useful tool for clinicians, policymakers and laypeople to understand the health impacts of dietary choices.'
The researchers added that there is significant uncertainty in their life expectancy estimates and that a variety of factors determine overall lifespan, such as potential treatment options for diseases.
They also said that while their calculations used data from a large number of studies, the overall quality of the evidence was moderate. They rated the evidence for whole grains on life expectancy as very high and the effects of eggs and white meat as very low.
The researchers compiled data from several meta-analyses on nutrition and life expectancy to create their calculator.
They said previous research suggests that nutritional risk factors stemming from people's diets are estimated to lead to 11 million deaths per year.

