Chocolate's minor reputation as a health food keeps growing: Eating chocolate up to six times a week can reduce your risk of developing a dangerous type of irregular heartbeat — atrial fibrillation, according to a study by Harvard and Danish researchers.

Atrial fibrillation or AFib (AF) is a serious condition that can cause blood clots and lead to stroke, heart failure and other heart problems. Nearly three million people live with it. Untreated, AFib doubles the risk of death from heart-related problems, and people with atrial fibrillation are five times more likely to have a stroke than those without a heart arrhythmia.

People who ate one to three one-ounce servings of chocolate per month had a 10 percent lower rate of AF than those who ate the same amount of chocolate less than once a month.

The study followed the diets, lifestyles and health conditions of over 55,000 men and women who were part of the Danish Diet, Cancer and Heath Study for three and a half years and through 13.5 years of follow-up. During this time, nearly 3,400 people in the study were diagnosed with atrial fibrillation.

People who ate one to three one-ounce servings of chocolate per month had a 10 percent lower rate of AF than those who ate the same amount of chocolate less than once a month. Eating one serving a week resulted in a 17 percent lower rate of AF, and people who indulged in two to six servings a week were 20 percent less likely to be diagnosed with AF. The benefits leveled off some as more chocolate was eaten. The effect was the same for both men and women.

The protection seems to come from chemical compounds called flavanols. They seem to act as antioxidants that protect cells from damage caused by the buildup of free radicals, waste products from chemical reactions in the body.

“Despite the fact that most of the chocolate consumed by the study participants likely had relatively low concentrations of potentially protective ingredients, we still observed a significant association between eating chocolate and a lower risk of AF — suggesting that even small amounts of cocoa consumption can have a positive health impact,” said Elizabeth Mostofsky of the Harvard Chan School of Public Health and lead author of the study, in a statement. She cautions that chocolate products are high in sugar, fat and calories, and excessive amounts could lead to weight gain and its associated metabolic problems.

What does this mean for you, the chocolate lover? Moderate amounts of chocolate can be part of a healthy diet. But if you want the most health bang for your buck, dark chocolate is a better choice than milk chocolate because it has not been processed as much as milk chocolate and is more likely to retain the health benefits provided by its flavanols.

The study is published in Heart.