This study investigates the influence of hydrostatic pressure on structural, electronic, mechanical and optical properties of Sr3PX3 (X = Cl and Br) compounds, by using the first-principles density functional theory (DFT) within the pressure range of 0–30 GPa with a span of 10 GPa. For Sr₃PCl₃ and Sr3PBr3, the dynamical stability is confirmed by the fact that the phonon dispersion curves do not contain imaginary modes. Pressure-induced band gap alterations in Sr3PCl3 and Sr3PBr3 reveal semiconducting behavior: GGA measurements show a decrease from 1.70 eV and 1.55 eV at ambient pressure to 0.22 eV and 0.21 eV at 30 GPa; TB-mBJ results show a decrease from 2.73 eV and 2.40 to 1.07 eV and 0.92 eV. This supports their inverse relationship with pressure. The values of Debye and melting temperatures support their high-temperature applications. Effective mass also shows an inverse relationship with induced pressure. The bond length, lattice parameters, and cell volume reduces with pressure. They exhibit ductility, which is further enhanced by the applied pressure. These materials emerge as promising candidates for flexible optoelectronic devices. Optical properties like absorption coefficients, reflectivity, and dielectric functions were observed and found to be significantly influenced by applied pressure. The absorption spectra exhibit a significant redshift with increasing pressure, indicating enhanced potential for optoelectronic applications. Our detailed investigation sheds light on the tunability of Sr3PX3 (X = Cl and Br) properties under pressure, showcasing their potential for cutting-edge applications in optoelectronics and photovoltaics.