Bond length and bond angle exhibited by valence electrons is essential to the core of chemistry. Using lead-based organic–inorganic perovskite compounds as an exploratory platform, it is demonstrated that the modulation of valence electrons by compression can lead to discovery of new properties of known compounds. Yet, despite its unprecedented progress, further efficiency boost of lead-based organic–inorganic perovskite solar cells is hampered by their wider bandgap than the optimum value according to the Shockley–Queisser limit. By modulating the valence electron wavefunction with modest hydraulic pressure up to 2.1 GPa, the optimized bandgap for single-junction solar cells in lead-based perovskites, for the first time, is achieved by narrowing the bandgap of formamidinium lead triiodide (HC(NH2)2PbI3) from 1.489 to 1.337 eV. Strikingly, such bandgap narrowing is partially retained after the release of pressure to ambient, and the bandgap narrowing is also accompanied with double-prolonged carrier lifetime. With First-principles simulation, this work opens a new dimension in basic chemical understanding of structural photonics and electronics and paves an alternative pathway toward better photovoltaic materials-by-design.