A compact fluoride conversion coating was prepared on AZ31B magnesium alloy by reaction with hydrofluoric acid. Morphology, composition and corrosion resistance of the coating were studied. The SEM examination showed that a compact film with some irregular distributed pores was formed on the surface of sample. The XPS analysis indicated that the coating was mainly composed of MgO and MgF2. Potentiodynamic polarization indicated that the fluoride conversion coating resulted in higher corrosion potential, lower corrosion current density, and a significant enhancement in corrosion resistance of AZ31B. The phosphate-calcium coating formed on the surface of fluoride treated AZ31B indicated a good bioactivity of the material.