Cobalt sulfides have attracted much attention as multifunctional electrocatalysts to trigger important reactions, for example, hydrogen evolution, oxygen evolution, and oxygen reduction reactions, and as electrodes for lithium or sodium ion storage. Nevertheless, the delivery of cobalt sulfide structures with high performance with long-term stability is still a challenge. In the current work reported here, via employing a metal–organic framework (MOF) as the starting material, a simple oxygen-assisted etching strategy to synthesize Co9S8 nanoparticles coated with N-doped few-layer graphene (CS@NFLG) was developed. Microstructure studies show that the graphene layer is doped with the nitrogen element and forms a continuous three-dimensional (3D) conductive network, which protects the inner Co9S8 nanoparticles in the harsh reaction environment and modulates the electronic interactions with the Co9S8 particle surface. Because of the advantages of the unique microstructure, CS@NFLG possesses excellent HER activity in an acidic medium (0.5 M H2SO4) at a low onset overpotential of 50 mV with a small Tafel slope of 73 mV dec−1. Meanwhile, the sample presents remarkable sodium storage properties in terms of a high reversible capacity, good rate capabilities, and good stability. In particular, the CS@NFLG electrode delivers a specific capacity of 505 mA h g−1 after 100 cycles at 0.5 A g−1. Moreover, the CS@NFLG electrode still maintains a high specific capacity of 442.3 mA h g−1 after 400 cycles at a high current density of 1.2 A g−1. This work shows that nanoscale “top-down” etching from the bottom is a promising route for the fine modulation of the structure and composition at the electronic and atomic scales, thus showing great prospects for use in energy storage and conversion applications.