Development of nitrogen-doped carbon materials with well-defined nanoporous structure is critical due to their versatile applications for the electrochemical energy conversion and storage devices. In this work, we report a new and facile strategy for the synthesis of N-doped nanoporous carbon materials (NNC) with adjustable nitrogen content (3.63–5.37%), large surface area (1942m2 g−1), uniform and well-defined nanopores (∼0.85–1nm) and high nanopore volume (0.53–0.88cm3g−1) derived from octa(aminophenyl)silsesquioxane (OAPS). OAPS is miscible with phenolic resol, forming an uniformly distributed and self-templated and cross-linked copolymer of OAPS and resol and NNC materials after carbonization and removal of monodispersed silica domains. The symmetric supercapacitor assembled by the electrodes with OAPS to resol ratio of 95:5 in 1M H2SO4 electrolyte exhibits the high specific capacitance of 230Fg−1 at 1Ag−1 due to the pseudocapacitive contribution of the N-groups, and delivers a high energy density of 5Whkg−1 with a power density of 1445Wkg−1 and high stability with performance loss of less than 5% over 10,000 cycles at 50mVs−1.