Efficient electrocatalysts for oxygen reduction reaction (ORR) are desirable but challenge in harsh conditions, which seriously limits the widespread application of many clean energy devices. Herein, a series of zeolitic imidazolate framework-8 (ZIF-8) assemblies are fabricated using a freestanding template and further used as pyrolytic precursors for synthesizing metal-free ORR catalysts. Impressively, the optimized 3D porous nitrogen-doped carbon (PNC-30) exhibits a half-wave potential of 0.90 and 0.76 V in alkaline and acidic electrolytes, respectively. Furthermore, when used as the cathode in zinc-air batteries, PNC-30 reaches a power density of 150 mW cm−2, 1.6 times higher than the commercial Pt/C. And, the PEMFCs equipped with PNC-30 cathode deliver a high power density of 562 W g−1. Experimental results and computational analysis indicate that the outstanding ORR performance is ascribed to the unique trimodal-porous structure, where micropores give abundant active sites/defects and meso-/macropores provide rapid mass transfer capabilities.