Magnesium sulfate (or magnesium sulphate) is a chemical compound containing magnesium, sulfur and oxygen, with the formula MgSO4. In its hydrated form the pH is 6.0 (5.5 to 6.5). It is often encountered as the heptahydrate, MgSO4Â·7H2O, commonly called Epsom salt. Anhydrous magnesium sulfate is used as a drying agent. Since the anhydrous form is hygroscopic (readily absorbs water from the air) and is therefore difficult to weigh accurately, the hydrate is often preferred when preparing solutions, for example in medical preparations. Epsom salt has been traditionally used as a component of bath salts. Oral magnesium sulfate, or magnesium hydroxide, is commonly used as a saline laxative. Epsom salt is also available in a gel form for topical application in treating aches and pains.