Hydrogen strongly affects the electronic and structural properties of many materials. It can bind to defects or to other impurities, often eliminating their electrical activity: this effect of defect passivation is crucial to the performance of many photovoltaic and electronic devices. A fuller understanding of hydrogen in solids is required to support development of improved hydrogen-storage systems, proton-exchange membranes for fuel cells, and high-permittivity dielectrics for integrated circuits. In chemistry and in biological systems, there have also been many efforts to correlate proton affinity and deprotonation with host properties. Here we report a systematic theoretical study (based on ab initio methods) of hydrogen in a wide range of hosts, which reveals the existence of a universal alignment for the electronic transition level of hydrogen in semiconductors, insulators and even aqueous solutions. This alignment allows the prediction of the electrical activity of hydrogen in any host material once some basic information about the band structure of that host is known. We present a physical explanation that connects the behaviour of hydrogen to the line-up of electronic band structures at heterojunctions.