 A facile preparation method was developed to obtain two-dimensional (2D) metal-free N, P-co-doped carbon nanosheets with sp2/sp3 interface derived from polymerizable ionic liquids (PIL) and ammonium nitrate (NH4NO3), exhibiting better electrocatalytic activity than that of the commercial Pt/C toward oxygen reduction reaction (ORR). The introduction of NH4NO3 can benefit the formation of carbon nanosheets structure and hierarchical porous structure due to decomposition and carbonization of polymer and gases emission resulting from ammonia nitrate, which can be confirmed by the SEM, TEM and BET results. The sp3 carbon and doping effect of heteroatoms of N, P can be investigated with the XPS, Raman and NEXAFS spectroscopy. The present work developed a facile method to prepare heteroatom-co-doped carbon as metal-free catalyst toward ORR with superior catalytic performance.