The recent discovery of more than a thousand planets outside our Solar System1,2, together with the significant push to achieve inertially confined fusion in the laboratory3, has prompted a renewed interest in how dense matter behaves at millions to billions of atmospheres of pressure. The theoretical description of such electron-degenerate matter has matured since the early quantum statistical model of Thomas and Fermi4,5,6,7,8,9,10, and now suggests that new complexities can emerge at pressures where core electrons (not only valence electrons) influence the structure and bonding of matter11. Recent developments in shock-free dynamic (ramp) compression now allow laboratory access to this dense matter regime. Here we describe ramp-compression measurements for diamond, achieving 3.7-fold compression at a peak pressure of 5 terapascals (equivalent to 50 million atmospheres). These equation-of-state data can now be compared to first-principles density functional calculations12and theories long used to describe matter present in the interiors of giant planets, in stars, and in inertial-confinement fusion experiments. Our data also provide new constraints on mass–radius relationships for carbon-rich planets.