Water treatment is required for a sustainable potable water supply and can be leveraged to harvest valuable elements. Crucial to these processes is the removal of charge pH-dependent species from polluted water, such as boron, ammonia, and phosphate. These species can be challenging for conventional technologies. Currently, boron removal requires several reverse-osmosis stages, combined with dosing a caustic agent. Capacitive deionization (CDI) promises to enable effective removal of such species without chemical additives. Here, we provide a detailed theory tackling this topic and show both theoretically and experimentally highly counterintuitive design rules governing pH-dependent ion removal by CDI.