To obtain pure sodium chloride, the crude salt is dissolved in minimum amount of water and filtered to remove insoluble impurities. The solution is then saturated with hydrogen chloride gas. Crystals of pure sodium chloride separate out.
Calcium and magnesium chloride, being more soluble than sodium chloride, remain in solution.