The compressibility of a medium, quantifying its response to mechanical perturbations, is a fundamental property determined by the equation of state. For gases of material particles, studies of the mechanical response are well established, in fields from classical thermodynamics to cold atomic quantum gases. Here we demonstrate a measurement of the compressibility of a two-dimensional quantum gas of light in a box potential and obtain the equation of state for the optical medium. The experiment is carried out in a nanostructured dye-filled optical microcavity. We observe signatures of Bose-Einstein condensation at high phase-space densities in the finite-size system. Strikingly, upon entering the quantum degenerate regime, the measured density response to an external force sharply increases, hinting at the peculiar prediction of an infinite compressibility of the deeply degenerate Bose gas.Quantum gases of atoms, exciton-polaritons, and photons provide a test bed for many-body physics under both in-and out-of-equilibrium settings [1][2][3]. Experimental control over dimensionality, potential energy landscapes, or the coupling to reservoirs offer wide possibilities to explore different phases of matter. For cold atomic gases, thermodynamic susceptibilities and transport properties have been extracted from density measurements [4][5][6][7][8][9] and have proven to be direct manifestations of the equation of state (EOS). In general, the EOS of a material, e.g., its pressure-volume relation, describes both the thermodynamic state of a system under a given set of physical conditions as well as its response to perturbations, as mechanical compression.Experimental investigations of the EOS in quantum gases constitute a tool for the characterisation of phases and the identification of phase transitions, enabling important tests of physical models in a wide range of systems, from the ideal gas to superfluids and the interior of stars.Quantum gases of light have so far been experimentally realized in low-dimensional settings, mostly twodimensional (2D) systems [3]. Thermalized photon gases with non-vanishing chemical potential µ, as well as Bose-Einstein condensation (BEC) have been demonstrated in dye-filled optical microcavities at harmonic confinement [10][11][12], including measurements of density-insensitive thermodynamic quantities [13]. In contrast, the isothermal compressibility κ T = n −2 (∂n/∂µ) T at temperature T depends on the (local) particle density n in the gas; for a systematic study, it thus is desirable to avoid spatially inhomogeneous density distributions inherent to harmonically trapped gases, and instead prepare uniform samples, where applying a spatially uniform force directly allows one to compress the gas and probe κ T .