In present study two condensation products of melamine (triazine) and glyoxal namely, 2,2-bis(4,6-diamino-1,3,5-triazin-2-ylamino)acetaldehyde (ME-1) and (N2,N2′E,N2,N2′E)–N2,N2′-(ethane-1,2-diylidene)-bis-(1,3,5-triazine-2,4,6-triamine) (ME-2) are tested as mild steel corrosion inhibitors in acidic solution (1M HCl). The inhibition efficiency of ME-1 and ME-2 increases with increase in their concentrations and maximum values of 91.47% and 94.88% were derived, respectively at 100 mgL−1 (34.20 × 10−5 M) concentration. Adsorption of ME-1 and ME-2 on the surface of metal obeyed the Langmuir adsorption isotherm. Polarization investigation revealed that ME-1 and ME-2 act as mixed type inhibitors with minor cathodic prevalence. The chemical and electrochemical analyses also supported by surface characterization methods where significant smoothness in the surface morphologies was observed in the images of SEM and AFM spectra. Several DFT indices such as EHOMO and ELUMO, ΔE, η, σ, χ, μ and ΔN were derived for both ME-1 and ME-2 molecules and correlated with experimental results. The DFT studies have also been carried out for protonated or cationic form of the inhibitor molecules by considering that in acidic medium the heteroatoms of organic inhibitors easily undergo protonation. The experimental and density functional theory (DFT) studies (neutral and protonated) were in good agreement.