Using hierarchically mesoporous silica spheres as a hard template and methyl violet as carbon and nitrogen source, nitrogen-doped hierarchically porous carbon spheres (N-HCS) are successfully prepared via a nanocasting method. The nitrogen-doped carbon spheres obtained after carbonization at 1000 °C (N-HCS-1000) exhibit a hierarchically micro-meso-macroporous structure with a relatively high surface area (BET) of 1413 m2 g−1 and a notably large pore volume of 2.96 cm3 g−1. In an oxygen reduction reaction (ORR) in alkaline media, the N-HCS-1000 material exhibits excellent activity with high current density, and its onset potential is notably close to that of the commercial Pt/C catalyst. The efficient catalytic activity of this catalyst could be attributed to the high electrical conductivity of the nitrogen-doped carbon matrix as well as the hierarchically porous framework. This catalyst also exhibits better methanol crossover resistance and higher stability than the commercial Pt/C catalyst.