One of the problems in the case of stainless steels is their low corrosion resistance against pitting corrosion in chloride containing environments, thereby leading to severe damage to industries. In this research, the pitting corrosion of 304 austenitic stainless steel was studied in 3.5% NaCl solution at room temperature (25˚C) by performing electrochemical measurements (containing cyclic polarization and electrochemical impedance spectroscopy) and immersion measurements. Moreover, the effect of adding different concentrations of PEI inhibitor with two mean molar masses (2000 and 60,000 g/mol) on pitting corrosion was investigated. Finally, the adsorption behavior of this inhibitor on the alloy surface was investigated by ATR-FT.IR and AFM methods. It was observed that both inhibitors prevented uniform and pitting corrosion successfully, but PEI (60,000 g/mol) had better inhibition efficiency than PEI (2000 g/mol).