Oxygen reduction reaction (ORR) and sulfur reduction reaction (SRR) play key roles in advanced batteries. However, they both suffer from sluggish reaction kinetics. Here, an interesting nitrogen doped porous carbon material that can simultaneously activate oxygen and sulfur is reported. The carbon precursor is a nitrogen containing covalent organic framework (COF), constituting periodically stacked 2D sheets. The COF structure is well preserved upon pyrolysis, resulting in the formation of edge-rich porous carbon with structure resembling stacked holey graphene. The nitrogen containing groups in the COF are decomposed into graphitic and pyridinic nitrogen during pyrolysis. These edge sites and uniform nitrogen doping endow the carbon product with high intrinsic catalytic activities toward ORR and SRR. The COF derived carbon delivers outstanding performances when assembling as cathodes in the Li-S and Li-O 2 batteries. Simultaneous activation of oxygen and sulfur also enables a new battery chemistry. A proof-of-concept Li-S/O 2 hybrid battery is assembled, delivering a large specific capacity of 2,013 mAh g −1 . This study may inspire novel battery designs based on oxygen and sulfur chemistry.