The charge storage mechanism and ion arrangement inside electrically charged carbon nanopores is a very active research field with tremendous importance for advanced electrochemical technologies, such as supercapacitors or capacitive deionization. Going far beyond the state of art, we present for the first time a comprehensive study of tracking ion electrosorption in aqueous electrolytes during charging and discharging of porous carbon electrodes using in situ X-ray scattering. We provide novel and quantitative insights into the local concentration of anions and cations and demonstrate that the global number of ions within the pores does not vary during charging and discharging. In addition, we have unique access to the spatial arrangement of ions inside carbon nanopores by using a simple, yet powerful two-phase model. Applying this model to our data, we show that double-layer formation is accomplished by a unique combination of preferred counter-ion adsorption directly at the pore wall which drains ions from their local surrounding inside carbon nanopores. Effectively, this leads to a situation which globally appears as ion swapping.
