The exploration of electrocatalysts for hydrogen evolution, that are stable and efficient in both acidic and alkaline media, is of the momentous importance in the advancement of clean energy production. This paper describes a modest, low-cost, and feasible method to synthesize hierarchical structures of Co 9 S 8 nanoparticles cocooned in the N-doped carbon layer (Co 9 S 8 -NDCL). First, the metal−organic framework, zeolitic imidazolate framework-67, was synthesized and then morphed into Co 9 S 8 -NDCL nanocomposites by thermal treatment with sulfur powder in an argon environment. The nanocomposite electrocatalyst boosts the efficient functioning in acidic (0.5 M sulfuric acid, H 2 SO 4 , pH = 0) and basic (1 M potassium hydroxide, KOH, pH = 14) conditions toward the hydrogen evolution reaction (HER). The improved electrocatalytic activity can be ascribed to the hierarchical, porous structure and synergy of Co 9 S 8 nanoparticles and the N-doped carbon layer. The Co 9 S 8 -NDCL nanocomposite electrode attains the current density of 20 mA.cm −2 for the HER, requiring very low overpotentials of 149 and 219 mV in 0.5 M H 2 SO 4 and 1 M KOH aqueous solutions, respectively. It is also observed that the Co 9 S 8 -NDCL nanocomposites, even after 2000 cycles, exhibited good stability and a small Tafel slope in both media. This study presents a mark in the race of achieving low-cost and highly efficient pristine Co 9 S 8 nanocomposites without doping of any precious metals.