This study examines the structural, electronic, and optical properties of K₂CaCdI₆ and K₂SrCdI₆ perovskites under varying hydrostatic pressures using density functional theory. The negative cohesive energies indicate that both perovskites exhibit stable structural integrity across different pressure levels, with the highest stability at ambient conditions. As the pressure increases, a notable cell compression is observed. The band gap of K₂CaCdI₆ increases from 1.54 to 1.99 eV, while for K₂SrCdI₆, it rises from 1.77 to 2.46 eV as pressure escalates from 0 to 6 GPa, suggesting a transition from semiconductor to insulator. Analysis of the density of states reveals that the I-5p orbital predominantly influences the valence band maximum, while the conduction band minimum is primarily governed by the Cd-5 s orbital. Furthermore, the study investigates the effects of hydrostatic pressure on the dielectric function, absorption coefficient, reflectivity, and refractive index, demonstrating enhanced UV absorption and reflectivity at elevated pressures. Both structures show absorption coefficients of 104 cm−1 order and about 27% reflectivity in the UV region at 0GPa. These findings provide valuable insights into the potential application of K₂CaCdI₆ and K₂SrCdI₆ perovskites in advanced optoelectronic devices that require pressure sensitivity and adjustable performance. © The Author(s), under exclusive licence to Springer Science+Business Media, LLC, part of Springer Nature 2024.