Washing soda reacts with soluble chlorides and sulphates of calcium and magnesium present in hard water to form insoluble carbonates which can be removed by filtration
CaCl2 + Na2CO3 ➝ CaCO3 ↓ + 2NaCl
MgCl2 + Na2CO3 ➝ MgCO3 ↓ + 2NaCl
CaSO4 + Na2CO3 ➝ CaCO3 ↓ + Na2SO4
MgSO4 + Na2CO3 ➝ MgCO3 ↓ + Na2SO4