Phytic acid (PA) conversion coating on AZ31 magnesium alloy is prepared by a deposition method. pH influences on the formation process, microstructure and properties of the conversion coating are investigated. Electrochemical tests including polarization curve and electrochemical impedance spectroscopy are used to examine the corrosion resistance, and scanning electron microscopy is used to observe the microstructure. The chemical nature of conversion coating is investigated by energy dispersive spectroscopy. And thermodynamic method is used to analyze the optimum pH. The results show that PA conversion coating can improve the corrosion resistance of AZ31 Mg alloy. The maximum efficiency achieves 89.19% when the AZ31 Mg alloy is treated by PA solution with pH=5. It makes the corrosion potential of sample shift positively about 156 mV and corrosion current density is nearly an order of magnitude less than that of the untreated sample. The thermodynamic analysis shows that the corrosion resistance of PA coatings is affected by not only the concentration of PA ion and Mg2+ but also the release rate of hydrogen.