We examine electronic and crystal structures of iron-based superconductors LnFeAsO1−x
H
x
(Ln = La, Sm) under pressure by means of x-ray absorption spectroscopy (XAS), x-ray emission spectroscopy (XES), and x-ray diffraction. In LaFeAsO the pre-edge peak on high-resolution XAS at the Fe-K absorption edge gains in intensity on the application of pressure up to 5.7 GPa and it saturates in the higher pressure region. We found integrated-absolute difference values on XES for Ln = La, corresponding to a spin state, decline on the application of pressure, and then it is minimized when the T
c approaches the maximum at around 5 GPa. In contrast, such the optimum value was not detected for Ln = Sm. We reveal that the superconductivity is closely related to the lower spin state for Ln = La unlike Sm case. We observed that As height from the Fe basal plane and As–Fe–As angle on the FeAs4 tetrahedron for Ln = La deviate from the optimum values of the regular tetrahedron in superconducting (SC) phase, which has been widely accepted structural guide to SC thus far. In contrast, the structural parameters were held near the optimum values up to ∼15 GPa for Ln = Sm.