Fluoride-incorporated plasma electrolytic oxidation (PEO) coating was fabricated on biodegradable AZ31 alloy. The surface morphologies and phases were investigated by scanning electron microscopy and X-ray diffraction. The effect of fluoride incorporation in coatings on corrosion behaviour was investigated in simulated body fluid and in vitro cytocompatibility of the coatings was also studied by evaluating cytotoxicity, adhesion, proliferation and live–dead stain of osteoblast cells (MC3T3-E1). Furthermore, the corrosion morphologies in vivo were examined. The results showed that the fluoride could be incorporated into the coating to form MgF2 phase. In vitro and in vivo degradation tests revealed that the corrosion resistance of the coating could be improved by the incorporation of fluoride, which may attribute to the chemical stability of MgF2 phase. Moreover, good cytocompatibility of fluoride-incorporated coating was confirmed with no obvious cytotoxicity, enhanced cell adhesion and proliferation. However, when the fluoride content was high, a slight inhibition of cell growth was observed. The results indicate that although fluoride incorporation can enhance the corrosion resistance of the coatings, thus resulting a more suitable environment for cells, the high content of fluoride in the coating also kill cells ascribed to the high released of fluorine. If the content of fluoride is well controlled, the PEO coating with MgF2 phase is a promising surface modification of Mg alloys.