Both magnesium chloride and sodium sulfate are ionic compounds. While the chemical formula of magnesium chloride is MgCl₂, the chemical formula of sodium sulfate or sodium sulphate is Na₂SO₄. In the chemical formula of sodium sulfate, Na is sodium (2 atoms) and SO₄ is the sulfate component wherein S is sulphur (1 atom) and O is oxygen (4 atoms).