Overview: Magnesium laxatives are used for occasional constipation. They work by pulling water into your intestines, which makes your poop softer and easier to pass. Diarrhea is a common side effect.