Strict control of the monodispersity and size of nanoparticles less than 200 nm is a prerequisite for many applications. However, template- and surfactant-free synthesis of monodisperse polymers and carbon nanospheres less than 200 nm is still challenging. In this paper, new polymer nanospheres were first synthesized by a sol-gel method via the polycondensation of phloroglucinol, p-phenylenediamine, and formaldehyde based on the benzoxazine chemistry in the absence of templates and/or surfactants. We proved the formation of a polybenzoxazine structure and found that p-phenylenediamine not only participates in the condensation but also catalyzes the polymerization of phloroglucinol and formaldehyde based on the characterization by FTIR, Raman, NMR, and XPS. The monodisperse polymer nanospheres are so uniform that they can form three-dimensional periodic structures by self-assembly. In addition, these polymer nanospheres can be pseudomorphically converted to the corresponding uniform nitrogen-doped carbon spheres by pyrolysis due to the excellent thermal stability (48.6 wt% at 1000 °C based on the measurement of TGA) of such polybenzoxazine-based polymers. The high nitrogen doping level of 9.77 wt% in the carbon matrix was achieved. The sizes of the polymer and carbon nanospheres can be adjusted, respectively, in the range of 105-186 and 79.2-137 nm by changing the concentration of monomers and the ratio of ethanol to water. To demonstrate their applicability, the electrodes for supercapacitors were prepared using nitrogen-doped carbon nanospheres without any activation and showed excellent performance. © 2018 The Royal Society of Chemistry.