Developing high-performance electrocatalysts for hydrogen evolution reaction (HER) is crucial for sustainable hydrogen production, yet still challenging. Here, we report boron-modulated osmium (B-Os) aerogels with rich defects and ultra-fine diameter as a pH-universal HER electrocatalyst. The catalyst shows the small overpotentials of 12, 19, and 33 mV at a current density of 10 mA cm−2 in acidic, alkaline, and neutral electrolytes, respectively, as well as excellent stability, surpassing commercial Pt/C. Operando X-ray absorption spectroscopy shows that interventional interstitial B atoms can optimize the electron structure of B-Os aerogels and stabilize Os as active sites in an electron-deficient state under realistic working conditions, and simultaneously reveals the HER catalytic mechanisms of B-Os aerogels in pH-universal electrolytes. The density functional theory calculations also indicate introducing B atoms can tailor the electronic structure of Os, resulting in the reduced water dissociation energy and the improved adsorption/desorption behavior of hydrogen, which synergistically accelerate HER.