© 2022, The Author(s), under exclusive licence to Springer Science+Business Media, LLC, part of Springer Nature.A density functional theory-based calculation of the magnetic structure, mechanical stability, electronic, and optical properties of quaternary Heusler alloys (QHAs) such as ZrCoFeX (X = Si, Ge) has been conducted. The most stable structure has been found among the various crystal arrangements of the alloys. Half-metallic ferromagnetism was obtained for both alloys where ZrCoFeGe has an indirect bandgap with 1.08 eV, and ZrCoFeSi has a direct bandgap with 1.36 eV. Calculated elastic constants and associated elastic parameters indicate both mechanical stability and ductility for ZrCoFeGe and ZrCoFeSi QHAs. The investigated alloys show high elasticity anisotropy. Optical properties such as absorption, reflectance, and conductivity have also been examined. ZrCoFeGe and ZrCoFeGe alloys indicate effective absorbing characteristics in the ultraviolet region and with high refractive indices. Both ZrCoFeGe and ZrCoFeSi QHAs have magnetic moments of around 1 μB which is promising for future spintronic applications.