This study is about making and figuring out what trimethoprim (TM), a popular corrosion inhibitor, is like and then using it as an inhibiting agent to stop corrosion in carbon steel in acid media (HCl solution) through adsorption. TM has also been known as the prevalent anti-corrosive agent. It can be added to a liquid or gas to slow the pace of a chemical reaction (in the case of a material – typically a metal or alloy – that corrodes when it encounters the fluid). Many antibiotic compounds, such as TM derivatives, diiron salt dihydrate, and diiron salt tetrahydrate, have active groups that can stop metal from corroding. Spectroscopic methods like XRD (X-ray difraction), FTIR (Fourier transform infrared spectroscopy), UV-visible (ultraviolet-visible spectroscopy), and TGA (thermogravimetric analysis) were used to study the TM drug. Similarly, the OCP (open circuit voltage) technique was introduced to assess the corrosion resistance and the density of current vs. voltage. Finally, this study revealed that TM drugs could be suggested for introduction as corrosion inhibitors due to their simple production and the fact that they have many active groups that exhibit the ability to coordinate with carbon steel. Our study revealed that changes in inhibitor concentrations, the solution's acidity, and the metal's surface area all contribute to adsorption.