Several harmful or valuable ionic species present in sea, brackish and wastewaters are amphoteric, and thus their properties depend on the local water pH. Effective removal of these species can be challenging by conventional membrane technologies, necessitating chemical dosing of the feedwater to adjust its pH. Capacitive deionization (CDI) is an emerging membraneless technique for water treatment and desalination, based on electrosorption of salt ions into charging microporous electrodes. CDI cells show strong internally-generated pH variations during operation, and thus CDI can potentially remove amphoteric species without chemical dosing. However, development of this technique is inhibited by the complexities inherent to coupling of pH dynamics and amphoteric ion properties in a charging CDI cell. Here, we present a novel theoretical framework predicting the electrosorption of amphoteric species in flow-through electrode CDI cells. We demonstrate that such a model enables deep insight into factors affecting amphoteric species electrosorption, and conclude that important design rules for such systems are highly counter-intuitive. For example, we show both theoretically and experimentally that for boron removal the anode should be placed upstream, which runs counter to accepted wisdom in the CDI field. Overall, we show that to achieve target separations relying on coupled, complex phenomena, such as in the removal of amphoteric species, a theoretical CDI model is essential.