The liver constantly secretes a bright green fluid called bile into the small intestine or it is stored in the gallbladder.
Bile is needed to absorb fats and fat soluble vitamins. It also helps to soften stools and is responsible for giving stools their characteristic brown color.
As bile makes its way through the intestines, it progressively changes color from green to yellow to brown, due to the action of bacteria in the large intestine on the bile salts.
Green stool often indicates that food has passed through the intestines faster than normal (called decreased bowel transit time), before it could be changed from green to brown.
vvvvv
Healthy people can have green poop if they eat a diet rich in leafy green vegetables, or if they consume large quantities of food coloring (in ice cream, cake frosting etc.).
Green poop can also be caused by excess iron in the diet, from dietary supplements, for example. If the body does not absorb all the iron consumed, the iron may stain the poop green, the color of iron (II) salts. Ordinarily, the green color may be masked by the normal brown poop color, but if digestion is thrown off by illness so that bilirubin is less concentrated in the intestine, the green color may become apparent. This can happen when a person is afflicted with diarrhea.
Green poop in sick babies may come from iron in baby formula not being properly absorbed, or by green pigments in bile salts (again, green from iron).
there ya go, now im a shitspert.