Sodium hexametaphosphate is called calgon. Its molecular formula is (NaPO3)6 or Na6P6O18.
The addition of Calgon to hard water causes the calcium and magnesium ions of hard water to displace sodium ions from the anion of Calgon. This results in the removal of calcium and magnesium ions from hard water in the form of a complex with Calgon. The water is softened and sodium ions are released into water.