Abstract The inhibition effect of new heterocyclic compounds, namely 2-aryl-benzothiazin-3-one (P1) and 3-aryl-benzothiazin-2-one (P2) on mild steel corrosion in 1M HCl was investigated using electrochemical measurements. The results indicated that the inhibition efficiency depends on concentration and molecular structure of the investigated compounds. It is also found that the inhibition of P1 is greater than P2. The molecular structure effect on the corrosion inhibition efficiency was investigated using DFT calculations. The structural and electronic parameters were calculated and discussed. The obtained results show that the experimental and theoretical studies agree well and confirm that P1 is the better inhibitor.