You know digging into that bean burrito will give you gas, but do you know why it happens? The culprit is fiber. Beans are rich in dietary fiber, an insoluble carbohydrate. Although it is a carbohydrate, fiber is an oligosaccharide that your digestive tract doesn't break down and use for energy, as it would simple sugars or starch. In the case of beans, insoluble fiber takes the form of three oligosaccharides: stachyose, raffinose, and verbascose.
So, how does this lead to gas? The oligosaccharides pass untouched through your mouth, stomach, and small intestine, to your large intestine. Humans lack the enzyme needed to metabolize these sugars, but you host other organisms that can digest them just fine. The large intestine is home to bacteria you need because they break down molecules your body cannot, releasing vitamins that are absorbed into your blood. The microbes also possess enzymes to break the oligosaccharide polymers into simpler carbohydrates. Bacteria release hydrogen, nitrogen, and carbon dioxide gasses as waste products from the fermentation process. About a third of the bacteria can produce methane, another gas.
The more fiber you eat, the more gas is produced by the bacteria, until you feel an uncomfortable pressure. If the pressure against the anal sphincter becomes too great, the pressure is released as flatus or farts.
Preventing Gas from Beans
To some extent, you are at the mercy of your personal biochemistry where gas is concerned, but there are steps you can take to reduce gas from eating beans. First, it helps to soak the beans several hours before cooking them. Some fiber will be washed away when you rinse the beans, plus they will begin to ferment, releasing gas beforehand. Be sure to cook them thoroughly, because raw and undercooked beans can give you food poisoning.
If you are eating canned beans, you can discard the liquid and rinse the beans before using them in a recipe.
The enzyme alpha-galactosidase can break down oligosaccharides before they reach the bacteria in the large intestine. Beano is one over-the-counter product that contains this enzyme, produced by the Aspergillus niger fungus. Eating the sea vegetable kombu also makes beans more digestible.