Heteroatom-doped porous carbon materials are highly desired for supercapacitors. Herein, we report the preparation of such material from polybenzoxazine (PBZ), a kind of phenolic resin. Four different N- and O-codoped microporous carbon materials were obtained by changing carbonization temperature (600, 700, 800, and 900 °C). Their structures were characterized by scanning electron microscopy (SEM), nitrogen isothermal absorption and desorption, X-ray diffraction (XRD), Raman spectroscopy, elemental analysis and X-ray photoelectron spectroscopy (XPS), and their electrochemical performances were evaluated by cyclovoltammetry (CV) and galvanostatic charge–discharge (GCD) test in a three-electrode system. It was found that the carbon material (C-700) prepared at the carbonization temperature of 700 °C possesses the largest specific surface area (SSA), total pore volume and average pore size among the family, and thus displays the highest specific capacitance with a value of 205 F g−1 at a current density of 0.25 A g−1 and good cycling stability. The work demonstrates that the N- and O-codoped microporous carbon materials with high electrochemical performance can be derived from benzoxazine polymers and are promising for supercapacitor application.