Highly porous nitrogen-doped carbon nanomaterials have distinct advantages in energy storage and conversion technologies. In the present work, hydrothermal treatments in water or ammonia solution were used for modification of mesoporous nitrogen-doped graphitic carbon, synthesized by deposition of acetonitrile vapors on the pyrolysis products of calcium tartrate. Morphology, composition, and textural characteristics of the original and activated materials were studied by transmission electron microscopy, X-ray photoelectron spectroscopy, near-edge X-ray absorption fine structure spectroscopy, infrared spectroscopy, and nitrogen gas adsorption method. Both treatments resulted in a slight increase in specific surface area and volume of micropores and small mesopores due to the etching of carbon surface. Compared to the solely aqueous medium, activation with ammonia led to stronger destruction of the graphitic shells, the formation of larger micropores (1.4 nm vs. 0.6 nm), a higher concentration of carbonyl groups, and the addition of nitrogen-containing groups. The tests of nitrogen-doped carbon materials as electrodes in 1M H2SO4 electrolyte and sodium-ion batteries showed improvement of electrochemical performance after hydrothermal treatments especially when ammonia was used. The activation method developed in this work is hopeful to open up a new route of designing porous nitrogen-doped carbon materials for electrochemical applications.