Pyridine (P1) and benzoic acid (P2) derivatives with pyrazole moieties were synthesized and evaluated as corrosion inhibitors for mild steel in acidic medium. The evaluation was performed by electrochemical impedance spectroscopy (EIS), potentiodynamic polarization, and weight loss measurement. The surface morphologies of the control and steel samples coated with the pyrazole derivatives P1 and P2 were examined by the scanning electron microscopy (SEM), UV-Vis, and X-ray photoelectron spectrocopy (XPS) spectroscopies. Results revealed minor changes on steel surfaces before and after immersion in a 1 M HCl solution. Both derivatives, P1 and P2, showed good inhibition efficiency that is dependent on inhibitor concentration. Both P1 and P2 act as mixed-type inhibitors. The benzoic acid derivative (P2) showed a higher efficiency than P1, which could be attributed to the carboxyl group that is located at the para position to the amino group. This induces a direct electronic resonance between the two groups, the amino and the carboxyl. As a result of this, a higher electron density on the carboxyl group and a stronger bonding to the metal surface occurred. Results also show that, the bonding of both pyrazoles on mild steel surface obey Langmuir adsorption isotherm. Quantum chemical calculations were performed to theoretically define the relationship between the molecular structures and inhibition efficiencies of P1 and P2.