The present study has been performed with the help of density functional theory to investigate structural, electronic, hydrogen storage, mechanical, thermal, and optical properties of KXH3 (X = Ca, Sc, Ti, & Ni) hydride perovskites. The lattice parameters are calculated by using the GGA-PBE functional and are found as 4.482 Å, 4.154 Å, 3.974 Å, and 3.686 Å for KCaH3, KScH3, KTiH3, and KNiH3, respectively. The electronic properties reveal that all the materials exhibit metallic behavior except KCaH3, which shows a semiconducting behavior. The population analysis suggests these compounds can store hydrogen due to their strong bonds and long bond lengths. The dynamic and mechanical stability predict that studied materials can be experimentally synthesized as the materials are thermodynamically and mechanically stable. The gravimetric ratio of hydrogen storage capacities has been calculated as 3.646 wt%, 3.452 wt%, 3.346 wt%, and 3.005 wt% for KCaH3, KScH3, KTiH3, and KNiH3, respectively. The calculated temperatures for hydrogen desorption are as follows: 442.40 K for KCaH3, 518.68 K for KScH3, 592.47 K for KTiH3, and 614.82 K for KNiH3, the formation energy was analyzed in the range − 57.822 to -80.358 KJ/mol.H2. These parameters suggest that all the materials are capable of hydrogen storage applications.