Magnesium is a chemical element with atomic number 12 and the element symbol Mg, which belongs to the group of alkaline earth metals. Magnesium is a divalent cation , which is important in water treatment , especially when water softening through ion exchange .

Just like with calcium , the divalent nature of magnesium is crucial for the exchange resin in a softening system to absorb magnesium and exchange it for sodium . Along with calcium, magnesium is the main cause of limescale deposits, which can occur when water is hard. Water that contains a lot of calcium and magnesium has a high water hardness .