Hollow nanostructured materials present a class of promising electrode materials for energy storage and conversion. Herein, 3D hollow nitrogen-doped carbon shells decorated with well-defined cobalt sulfide nanoparticles (Co9S8/HNCS) have been constructed for superior lithium and sodium storage. Two steps are involved in the designed preparation procedure. First, hollow intermediates with preserved cobalt components are controllably fabricated by simultaneously dissociating cobalt containing zeolitic-imidazolate-frameworks-67 (ZIF-67), and polymerizing dopamine in a Tris–HCl solution (pH = 8.5). The polydopamine (PDA) wrapped intermediates inherits the polyhedral structure of the ZIF-67 crystals. In the second step, the final Co9S8/HNCS composite is obtained via a combined carbonization and sulfurization treatment of the intermediates, allowing the formation of hollow polyhedrons of nitrogen-doped carbon shells (900±100 nm) derived from PDA and the encapsulation of highly uniform cobalt sulfide nanoparticles (11±2 nm). This configuration is believed to not only shorten the lithium or sodium ion diffusion distance and accommodate volume change during lithium or sodium ion insertion/extraction, but also to enhance the overall electrical conductivity and the number of active sites. As a result, the Co9S8/HNCS composite exhibits an impressive reversible capacity of 755 mA h g-1 at 500 mA g-1 after 200 cycles for lithium ion storage, and capacities of 327 mA h g-1 at 500 mA g-1 after 200 cycles and 224 mA h g-1 at 1000 mA g-1 after 300 cycles for sodium ion storage. Essential factors especially the structural stability during cycling have been identified, and the discharge/charge mechanism is discussed.