Nitrogen-doped carbons (NCs) have demonstrated notable advantages for application in capacitive deionization (CDI). However, the potential roles of different nitrogen configurations in the CDI process, especially how the neglected oxygen doping synergistically works, remain unclear. In this work, we systematically addressed these critical issues and revealed the significant role of trace oxygen doping in enhancing the desalination performance of NC electrodes. By introducing oxygen into nitrogen-doped carbon nanosheets (ONC-S), using guanine as the precursor, we obtained abundant pyridinic and pyrrolic nitrogen configurations. This design aims to synergistically enhance the charge distribution, wettability, and ion diffusion of the target electrodes. Compared with commercial activated carbon and other state-of-the-art materials, our ONC-S electrode demonstrates superior specific capacitance, excellent cycling stability, and enhanced desalination efficiency. These findings highlight the synergistic effects of trace oxygen doping and the nitrogen configuration, offering valuable insights into the mechanisms driving the improved CDI performance. Nitrogen-doped carbons (NCs) have shown significant potential for capacitive deionization applications, but the roles of different nitrogen configurations and the synergistic effect of oxygen doping remain unclear. Here, this study addresses these issues and reveals the crucial impact of trace oxygen doping in enhancing the desalination performance of NC electrodes.