Nitrogen-doped hollow mesoporous carbon spheres have drawn much attention in many applications, including adsorption, catalysis and energy storage, etc. because of their hollow structure, thin carbon shell, and high specific surface area. Herein, a confined-space pyrolysis method is applied for the preparation of nitrogen-doped hollow mesoporous carbon sphere with uniform spherical morphology, relative large cavity, and high specific surface area, using polystyrene/polyacrylonitrile (PS/PAN, or PSPAN) spheres as a carbon precursor. In this process, mesoporous silica shell is coated on the PSPAN spheres to provide a confined space, in which a regular spherical morphology of nitrogen-doped hollow mesoporous carbon sphere can be obtained after the process of pyrolysis. The in situ generation of CO2 and H2O from PSPAN spheres play the role of active agent, creating a rich and uniform mesoporous distribution for nitrogen-doped hollow mesoporous carbon spheres, which is conducive to fast charge transport. Rich nitrogen content in PAN results in in situ nitrogen doping. Adjusting the PS:PAN ratio can realize the adjustment of diameter and cavity size. As an electrode in a supercapacitor, the nitrogen-doped hollow mesoporous carbon sphere exhibits outstanding performance with large specific capacitance, indicating its excellent promise in energy storage.