The Co nanoparticles encapsulated inside Co and nitrogen co-doped carbon catalysts with small particle size and homogenous distribution of Co NPs were elaborately synthesized, which exhibit evidently outstanding activity and stability toward ORR/HER.