We have developed a new all-optical method to directly measure the pressure–volume–temperature (PVT) equation of state (EOS) of fluids and transparent solids in the diamond anvil high pressure cell by measuring the volume of the sample chamber. Our method combines confocal microscopy and white light interference with a new analysis method, which exploits the mutual dependence of sample density and refractive index: Experimentally, the refractive index determines the measured sample chamber thickness (and therefore the measured sample volume/density), yet the sample density is by far the dominant factor in determining the variation in the refractive index with pressure. Our analysis method allows us to obtain a set of values for the density and refractive index, which are mutually consistent and agree with the experimental data within error. We have conducted proof-of-concept experiments on a variety of samples (H2O, CH4, C2H6, C3H8, KCl, and NaCl) at ambient temperature and at high temperatures up to just above 500 K. Our proof-of-concept data demonstrate that our method is able to reproduce known fluid and solid EOS within error. Furthermore, we demonstrate that our method allows us to directly and routinely measure the PVT EOS of simple fluids at GPa pressures up to, at least, 514 K (the highest temperature reached in our study). A reasonable estimation of the known sources of error in our volume determinations indicates that the error is currently ±2.7% at high temperature and that it is feasible to reduce it to ca. ±1% in future work.