The electrochemical polymerization of polypyrrole (Ppy) films on AZ31Mg alloys was carried out using cyclic voltammetery in 0.5 M sodium salicylate solution containing 0.25 M pyrrole and different concentration of sodium fluoride (NaF). Corrosion performance of the Ppy film was assessed by electrochemical impedance spectroscopy (EIS) and potentiodynamic polarization tests in 3.5 % NaCl solution. It was observed that Ppy coatings doped in the presence of 100 ppm NaF provide the best corrosion protection for magnesium and the corrosion potential shifted about 290 mV toward nobler potentials and decrease the corrosion current density about one order of magnitude. The surface analysis of the coatings showed that the addition of F− dopant anions led to an improvement in the smoothness, thickness, and adhesion quality of the synthesized Ppy coating on the Mg surface. The scanning electron microscopy (SEM) studies of the fluoride-doped Ppy films revealed that the synthesized coating has a closely packed globular structure which was composed of nanoparticles of Ppy.