The structures and compositions of materials have important influences on their performance. Herein, hierarchically structured yolk-shell Co and N codoped porous carbon microspheres (YS-Co/N-PCMs) have been successfully synthesized by using low-cost melamine, formaldehyde and cobalt acetate as raw materials via a facile template-free hydrothermal method and a subsequent pyrolysis. The formation process of the yolk-shell precursor is systematically investigated, involving a morphological evolution process from solid microspheres, ultrathin and wrinkled shells wrap, to yolk-shell structure formation. More importantly, the unique structure combines the favorable features towards oxygen reduction reaction (ORR), such as high surface area, sufficient Co-Nx and graphitic N active sites and suitable pore structures. As a result, the YS-Co/N-PCMs catalyst shows high catalytic activity for ORR in alkaline media for fuel cells, which not only outperforms commercial Pt-based catalysts in terms of resistance to methanol crossover and long-time stability, but is also better than many non-precious metal doped carbon-based catalysts reported previously. In addition, the YS-Co/N-PCMs catalyst also has high catalytic activity toward oxygen evolution reaction (OER). Therefore, the YS-Co/N-PCMs catalyst may serve as a promising alternative to Pt/C catalyst for ORR and OER in alkaline media.