Doping graphene with foreign elements is an effective way to tune its physicochemical properties, thus paving a new way to enhance its practical application. Nitrogen (N) and Boron (B) are one of the most frequently used dopants, especially in water purification, desalination, and electrocatalysis. Despite its importance, the interaction between N and B-doped graphene and alkaline metals (Na and K) and their ions (Na+ and K+) that must be captured to purify the water remains ambiguously. In this work, we use the density functional theory with the dispersion correction to systematically study the interaction of graphene doped with the graphitic N and B-structures with Na, K, Na+ and K+. Alkali metals and ions interact repulsively with the N site; whereas they interact attractively with the B site. Energetically, Na and K tend to desorb on N-doped graphene while B-doped graphene further strengthens the Na and K adsorption. Electronic structure analysis implies that the adsorbates tend to donate an electron to the graphene substrate. The origin leading to the different adsorption behavior upon N and B doping is attributed to the fact that a lower perturbation of the π-electrons of graphene strengthens the alkali metals-graphene interaction. B doping or p-typed doping has great implications for doped graphene’s electronic properties and the enhanced alkaline capture ability, thus would be helpful in desalination for water purification.