The typical water softener is a mechanical appliance that's plumbed into your home's water supply system. All water softeners use the same operating principle: They trade the minerals for something else, in most cases sodium. The process is called ion exchange
The heart of a water softener is a mineral tank. It's filled with small polystyrene beads, also known as resin or zeolite. The beads carry a negative charge.
Calcium and magnesium in water both carry positive charges. This means that these minerals will cling to the beads as the hard water passes through the mineral tank. Sodium ions also have positive charges, albeit not as strong as the charge on the calcium and magnesium. When a very strong brine solution is pushed through a tank that has beads already saturated with calcium and magnesium, the sheer volume of the sodium ions is enough to drive the calcium and magnesium ions off the beads. Water softeners have a separate brine tank that uses common salt to create this brine solution.