A5B19-type superlattice structure La–Mg–Ni-based alloys are potential anode material for nickel-metal hydride batteries due to outstanding durability and rate capability. However, the formation of multi-phase structures compromises cycling stability and poses the challenge in determining the specific effect of the element based on multiple components. Herein, we obtain Pr5Co19-type single-phase alloys and further study the effect of Mg element on structure and performance. It is found that the increased Mg strengthens the structure stability via reducing the volume mismatch between subunits and contributing to the weaken alloy pulverization. The optimized A5B19-type La0.58Sm0.18Y0.01Mg0.23Ni3.62Al0.16 alloy displays superior capacity durability with a capacity retention rate of 71.6% after 300 cycles, while that of La0.58Sm0.21Y0.01Mg0.20Ni3.62Al0.16 alloy is 68.1%. Besides, the increased Mg also optimizes the discharge performance at low temperature and high rate. The work aims to guide the design of composition and structure for hydrogen storage alloy with long period.