The development of efficient and cost-effective electrocatalysts for hydrogen evolution reaction (HER) is of current interest. Pyrolysis of 3d metal complexes or mixtures of 3d metal ions and N-containing organic ligands has been found to be an efficient way to afford cost-effective metal-and N-doped carbon electrocatalysts for HER. However, due to the multiplecomponents nature of the catalysts, it is a challenge to clarify the role of each component. Herein, we report a facile approach to prepare Co-and N-doped carbon catalysts with carbon nanotubes uniformly grafted over the carbon layers via pyrolysis of a Co complex precursor bearing 2,4-diamino-6-pyridyl-1,3,5-triazine ligand. Among the prepared catalysts, Co−N/CNT/C-850 exhibits the best performance as a pH-universal electrocatalyst for HERs, which requires small overpotentials of 120, 190, and 134 mV to achieve a current density of 10 mA cm −2 in 1 M KOH, 1 M phosphate buffer solution (PBS, pH = 7), and 0.5 M H 2 SO 4 , respectively. Experimental results and theoretical calculations revealed that the Co 2+ dopant played a vital role in tuning the electronic structure of the carbon skeleton, leading to boosted HER catalytic activity of adjacent carbon atoms. Our work should provide insight into the design of metal carbon composites materials for energy conversion.