Directly pyrolyzing organometal complex represents a judicious strategy to fabricate efficient multifunctional carbon-based electrocatalysts, but the structure/composition of the catalysts is commonly complicated and the corresponding electrocatalytic activities are usually compromised. In this study, we report a selective leaching route to prepare small Co9S8 nanoparticles supported on nitrogen, sulfur codoped porous carbon nanosheets (Co9S8@PNSC) by pyrolyzing sheet-like Co(II)-coordinated thiourea-ethylenediamine-formaldehyde resin (Co-TEFR)/polydopamine (PDA) hybrids that are covered by silica shell layer, followed by removal of the silica and Co nanoparticles with NH4HF2 through a wet etching method. Consequently, the resultant Co9S8@PNSC exhibits high specific surface area, hierarchical porosity and tiny Co9S8 nanoparticles, which are conducive to the maximal utilization of active sites, endowing remarkable oxygen electrocatalysis with a half-wave potential of +0.845 V for oxygen reduction reaction and a low overpotential of 314 mV at current density of 10 mA cm−2 for oxygen evolution reaction. Besides, such composite also shows a considerable electrocatalytic performance for hydrogen generation. When applied in an assembled zinc-air battery, Co9S8@PNSC displays a high power-density (203 mW cm−2) and favorable cycling lifespan. The results from the present strategy may provide an exemplification in rational design and fabrication of carbon-based nanocomposite for high-performance multifunctional electrocatalysis.