We report here the synthesis of N-doped porous carbon (PC) through a convenient melamine pre-grafting strategy. The melamine derivative with a monolayer structure was first grafted on the surface of the micropores of PC using a suitable diazotization reaction of melamine in an aqueous solution. After pyrolysis, PC grafting with melamine derivative was converted to the obtained N-doped PC. Meanwhile, more nitrogen dopants were grafted, and nitrogen functionalities were reconstructed to generate more graphitic N and pyridinic N atoms, in which the mesopores volume was consequently enlarged. Because of the unique structures mentioned above, the as-obtained N-doped PC exhibited enhanced oxygen reduction activity under alkaline compared with the N-doped PC from the standard physical mixture of PC and melamine. Besides, the obtained N-doped PC showed a comparable half-wave potential, remarkable durability, and good methanol tolerance compared with the commercial 20% Pt/C electrocatalyst. The results presented here could guide the development of new and improving metal-free nitrogen-doped porous carbon catalysts toward oxygen reduction reaction. • Melamine pre-grafting strategy boosts N dopants and optimizes pores for ORR. • Reconstruction enables more pyridinic and graphitic N dopants in PC. • Metal-free N-rich porous carbon has excellent ORR performance. [ABSTRACT FROM AUTHOR]