To prevent steel from corroding in HCl solution, a cost-effective inhibitor of Dactyloctenium aegyptium and KI is presented. UV–Vis, infrared spectroscopy, and scanning electron microscopy analysis are used to undertake a comprehensive experimental evaluation of the inhibitors and their interactions with the steel. The optimum concentration of the Dactyloctenium aegyptium extract (DAE) with the maximum corrosion protection efficacy is found via electrochemical measurements. The bioactive constituents of the DAE such as Tricin, Vanillic acid, p-hydroxybenzaldehyde, and p-hydroxybenzoic acid conferred a maximum inhibition efficiency of 95.7 % at 800 ppm. The inhibitory activity of its ethanolic extract increased with increasing concentration. Further various adsorption isotherm models including Langmuir, Temkin and Frendluich were used to understand the adsorption of the DAE on the metal surface. The DFT based investigations show that the active constituents of the DAE are highly polarized, soluble in aqueous solution and adsorb on the steel surface efficiently.