Optimizing the microenvironment of active sites is crucial for enhancing the catalytic activity of the hydrogen evolution reaction (HER) across various pH conditions. Here, guided by theoretical predictions of boron (B)-doping's electronic buffering effect on ruthenium (Ru) at the atomic scale, a highly efficient and universal-pH Ru-based HER electrocatalyst (Ru-NBC) by introducing B and nitrogen (N) into a carbon (C) matrix was designed. The Ru-NBC catalyst demonstrated exceptional HER activity, requiring overpotentials of 27, 40, and 68 mV in 1 M KOH, 0.5 M H