Nitrogen-doped mesoporous carbon (NMC) has been synthesized by sol–gel process using a mixture of phenol and formaldehyde as source of carbon, and melamine as source of nitrogen. The Ludox-AS40 (40 wt% SiO 2 ) is employed, for the first time, as hard template to obtain polymeric gel by prolonged heat treatment at 80 °C. The wt% of nitrogen is tuned by varying the weight ratio of melamine to phenol. Stable mesoporous carbon frameworks are obtained by pyrolysis of the dry gel at 800 °C in nitrogen atmosphere and treated with alkali to remove silica. One of the carbon framework samples has 11 wt% nitrogen doping and shows pore volume of 0.5 cm 3 g −1 and surface area 609 m 2 g −1 . The other carbon frame work sample has 6 wt% nitrogen doping and shows higher pore volume of 1.1 cm 3 g −1 and surface area 736 m 2 g −1 . The later sample exhibits highest electrochemical capacitance of 196 F g −1 at 0.5 A g −1 while the former shows only 146 F g −1 at 0.5 A g −1 . However, both the NMC electrodes show good cyclic performance (91% of the initial capacitance after 1000 cycles) in an aqueous KOH electrolyte. This study demonstrates that there is an optimum level of nitrogen doping required to keep the meso-structure of carbon network intact, simultaneously maintaining high surface area and sufficient electrical conductivity for electrochemical applications. © 2016 Elsevier B.V.