Capacitive deionization (CDI) has attracted huge interest as an emerging desalination technology. To explore carbon electrode materials with high performance is the key for CDI technology. In this work, the N-doped hierarchical porous carbon (N-HPC) was fabricated via pyrolysis of hypercrosslinked diblock copolymer (PEO113-b-PS192) with a nitrogen-enriched melamine. The as-prepared N-HPC was further applied as CDI electrode. This electrode showed enhanced electrochemical performance with a specific capacitance of 182.6Fg−1 and an outstanding electrosorption capacity of 13.76mgg−1 in 500mgL−1 NaCl solution, which are higher than those of its undoped counterpart (66.7Fg−1 and 10.27mgg−1, respectively). Such an improvement was attributed to synergistic effect from the combination of nitrogen-doped property and the hierarchical porous structure. After 6 adsorption-desorption cycles, a stable electrosorption capacity can be realized without appreciable declination, suggesting a good repeatability of electrosorption process. These results imply that N-HPC has great potential as a promising electrode material for CDI application.