The design and synthesis of a series of theophylline derivatives containing 1,2,3-triazole moieties are presented. The corrosion inhibition activities of these new triazole–theophylline compounds were evaluated by studying the corrosion of API 5 L X52 steel in 1 M HCl medium. The results showed that an increase in the concentration of the theophylline–triazole derivatives also increases the charge transference resistance (
R
ct
) value, enhancing inhibition efficiency and decreasing the corrosion process. The electrochemical impedance spectroscopy under static conditions studies revealed that the best inhibition efficiencies (approx. 90%) at 50 ppm are presented by the all-substituted compounds. According to the Langmuir isotherm, the compounds
4
and
5
analysed exhibit physisorption–chemisorption process, with exception of the hydrogen
3
, bromo
6
and iodo
7
substituted compounds, which exhibit chemisorption process. The corrosion when submerging a steel bar in 1 M HCl was studied using SEM-EDS. This experiment showed that the corrosion process decreases considerably in the presence of 50 ppm of the organic inhibitors. Finally, the theoretical study showed a correlation between E
HOMO
, hardness (
η
), electrophilicity (W), atomic charge and the inhibition efficiency in which the iodo
7
substituted compound presents the best inhibitor behaviour.