Summary Nitrogen-doped graphene (NG) is a promising metal-free catalyst for oxygen reduction reaction (ORR) in fuel cells and metal–air batteries. However, its practical application hinges on significant cost reduction by using novel synthetic methods and further improvement of the catalytic activity by increasing the density of catalytically active site. Here we report a low-cost, scalable, synthetic method for preparation of NG via pyrolysis of graphene oxide with a rationally selected N source polypyrrole. Because of the large number of N atoms in pyrrole ring, polypyrrole can facilitate the formation of graphitic N, which is considered vital for high catalytic activity. The resulting 3D porous structure of NG has an N doping level of 2–3at%, of which as high as 44% are graphitic N. Electrochemical characterizations show that NG has high catalytic activity toward ORR in an alkaline electrolyte via a favorable four-electron pathway for the formation of water, leading to high performance and low polarization loss. The NG also displays excellent long-term stability and resistance to methanol crossover, offering performance characteristics superior to those of a commercial Pt/C catalyst. The effect of pyrolysis temperature on the structure and property of NG are revealed using X-ray photoelectron spectroscopy and electrochemical measurements, providing important insights into the rational optimization of electrocatalytic activity for ORR. In addition, the NG also shows high catalytic activity toward oxygen evolution reaction (OER), rendering its potential application as a bifunctional electrocatalyst for both ORR and OER.