Gallstones form when substances in bile, the digestive fluid stored in your gallbladder, fall out of balance and harden into solid pieces. About 20 million people in the US have them, roughly 15% of the population. The process is gradual, often taking years, and it starts with changes in either the chemistry of your bile or the way your gallbladder contracts and empties.
What Bile Is and Why It Matters
Your liver continuously produces bile, a fluid that helps you digest fats. Between meals, bile flows into the gallbladder, a small pear-shaped organ tucked under your liver, where it’s stored and concentrated. When you eat, the gallbladder squeezes bile through a duct into your small intestine.
Bile is a mixture of cholesterol, bile salts, bilirubin (a waste product from broken-down red blood cells), and water. Normally these components stay dissolved in liquid form, the same way sugar stays dissolved in warm tea. Gallstones begin when one of those components becomes too concentrated for the others to keep it in solution.
How Cholesterol Stones Form
The vast majority of gallstones are cholesterol stones. Chemical analysis shows cholesterol accounts for an average of 77% of their dry weight. They form through a three-step process.
First, your liver secretes more cholesterol into bile than the bile salts can dissolve. This creates what’s called supersaturated bile. Second, the excess cholesterol begins precipitating out of the liquid as tiny solid crystals. A layer of mucus lining the gallbladder wall accelerates this step by acting as a scaffold that helps crystals form. Third, those microcrystals clump together and grow over time. If the gallbladder isn’t emptying well, the crystals sit in place long enough to aggregate into visible stones, sometimes as small as a grain of sand, sometimes as large as a golf ball.
Before actual stones appear, many people develop biliary sludge, a thick mixture of mucus, cholesterol microcrystals, and calcium salts. Sludge is often a precursor to stones. It tends to develop during periods when the gallbladder isn’t contracting regularly, such as during pregnancy or prolonged fasting.
How Pigment Stones Form
Pigment stones are dark brown or black and make up a smaller share of gallstones. They form when bile contains too much bilirubin. Your body produces bilirubin every time it recycles old red blood cells, and normally the liver processes it and sends it out in bile at manageable levels. But certain conditions cause bilirubin to accumulate: liver cirrhosis, infections in the bile ducts, and blood disorders that cause rapid breakdown of red blood cells (like sickle cell disease). The excess bilirubin combines with calcium and hardens into stones.
Risk Factors That Shift Bile Chemistry
Several things can tip your bile composition toward stone formation. Some you can control, others you can’t.
Body weight. Carrying excess weight increases the amount of cholesterol your liver puts into bile. The heavier you are, the more cholesterol-saturated your bile becomes. Paradoxically, losing weight too quickly is also a trigger. When you crash diet or go long stretches without eating, your liver releases extra cholesterol into bile and your gallbladder stops emptying properly, both of which promote crystal formation. Experts recommend losing no more than 5 to 10% of your starting weight over six months to keep the risk manageable.
Hormones and sex. Estrogen raises cholesterol levels in bile, while progesterone slows gallbladder contractions. This combination explains why women develop gallstones more frequently than men. Pregnancy doubles down on both effects: estrogen surges and the gallbladder becomes sluggish, which is why biliary sludge commonly develops during pregnancy. Hormone replacement therapy and some oral contraceptives carry similar risks through the same mechanism.
Age. Stone formation becomes more common after 40. As you age, your body tends to secrete more cholesterol into bile, and gallbladder motility gradually declines.
Genetics and ethnicity. Gallstones run in families. If your parents or siblings have had them, your risk is higher. Certain populations, particularly Indigenous peoples of the Americas, have significantly elevated rates, pointing to a strong genetic component in how the liver handles cholesterol.
Diabetes. People with diabetes tend to have higher triglyceride levels, which contribute to cholesterol-heavy bile. They also often have reduced gallbladder motility, giving crystals more time to form.
The Role of a Sluggish Gallbladder
Even if your bile chemistry is off, stones won’t necessarily form if your gallbladder empties completely and on schedule. Contraction flushes out early-stage crystals before they can grow. Impaired emptying is what gives stones the time they need. Think of it like a pond versus a river: still water grows algae, moving water doesn’t.
Several situations cause gallbladder stasis. Extended fasting, receiving nutrition intravenously in a hospital setting, pregnancy, and certain medications all reduce how often and how forcefully the gallbladder contracts. When bile sits in the gallbladder for too long, mucus accumulates, microcrystals bind together, and sludge thickens into stones.
What a Gallstone Attack Feels Like
Most gallstones cause no symptoms at all. You can carry them for years without knowing. Problems begin when a stone shifts and blocks one of the ducts that carry bile out of the gallbladder. This causes a sudden, intense pain in the upper right side of your abdomen or in the center just below your breastbone. The pain often radiates to your right shoulder or between your shoulder blades. It typically builds over minutes and can last anywhere from 30 minutes to several hours. Nausea and vomiting are common during an episode.
These attacks frequently happen after a fatty meal, because fat triggers the gallbladder to contract forcefully. If a stone is sitting near the duct opening, that contraction pushes it into a position where it blocks the flow of bile.
Dietary Factors That Affect Your Risk
What you eat plays a measurable role in whether stones form. Diets high in refined carbohydrates and saturated fat increase cholesterol saturation in bile. Diets rich in fiber do the opposite by binding bile salts in the intestine and pulling cholesterol out of circulation.
Coffee appears to be genuinely protective. A large study of women published in Gastroenterology found that those who drank four or more cups of caffeinated coffee per day had a 23 to 28% lower risk of developing symptomatic gallstones compared to non-drinkers. The benefit followed a dose-response pattern, meaning more coffee correlated with lower risk across every level of intake. The protective effect may come from caffeine stimulating gallbladder contractions, or from other coffee compounds like magnesium and niacin that were independently associated with reduced risk.
Maintaining a steady, healthy weight is one of the most practical things you can do. The combination of obesity increasing cholesterol in bile and rapid weight loss further destabilizing bile chemistry means the goal is gradual, sustained change rather than dramatic swings.

