Materials at high pressures and temperatures are of great interest for planetary science and astrophysics, warm dense-matter physics and inertial confinement fusion research. Planetary structure models rely on an understanding of the behaviour of elements and their mixtures under conditions that do not exist on Earth; at the same time, planets serve as natural laboratories for studying materials at extreme conditions. The topic of dense hydrogen is timely given the recent accurate measurements of the gravitational fields of Jupiter and Saturn, the current and upcoming progress in shock experiments, and the advances in numerical simulations of materials at high pressure. In this Review we discuss the connection between modelling planetary interiors and the high-pressure physics of hydrogen and helium. We summarize key experiments and theoretical approaches for determining the equation of state and phase diagram of hydrogen and helium. We relate this to current knowledge of the internal structures of Jupiter and Saturn, and discuss the importance of high-pressure physics to their characterization.