Carbon nanomaterials possessing a high specific surface area, electrical conductivity and chemical stability are promising electrode materials for alkali metal-ion batteries and supercapacitors. In this work, we study nitrogen-doped carbon (NC) obtained by chemical vapor deposition of acetonitrile over the pyrolysis product of calcium tartrate, and activated with a potassium hydroxide melt followed by hydrothermal treatment in an aqueous ammonia solution. Such a two-stage chemical modification leads to an increase in the specific surface area up to 1180 m2 g−1, due to the formation of nanopores 0.6–1.5 nm in size. According to a spectroscopic study, the pore edges are decorated with imine, amine, and amide groups. In sodium-ion batteries, the modified material mNC exhibits a stable reversible gravimetric capacity in the range of 252–160 mA h g−1 at current densities of 0.05–1.00 A g−1, which is higher than the corresponding capacity of 142–96 mA h g−1 for the initial NC sample. In supercapacitors, the mNC demonstrates the highest specific capacitance of 172 F g−1 and 151 F g−1 at 2 V s−1 in 1 M H2SO4 and 6 M KOH electrolytes, respectively. The improvement in the electrochemical performance of mNC is explained by the cumulative contribution of a developed pore structure, which ensures rapid diffusion of ions, and the presence of imine, amine, and amide groups, which enhance binding with sodium ions and react with protons or hydroxyl ions. These findings indicate that hydrogenated nitrogen functional groups grafted to the edges of graphitic domains are responsible for Na+ ion storage sites and surface redox reactions in acidic and alkaline electrolytes, making modified carbon a promising electrode material for electrochemical applications.