Hydroxyapatite/tannic acid coating (HA/TA) were prepared on AZ31 magnesium alloys (AZ31) via chemical conversion and biomimetic methods. The characterization and properties of the coating were studied by scanning electron microscopy (SEM), X-ray diffraction (XRD), Fourier transform infrared spectroscopy (FTIR), corrosion testing, MC3T3-E1 cell proliferation assay, and MC3T3-E1 cell morphology observation. The results showed that tannic acid as an inducer increased the number of nucleation centers of hydroxyapatite and rendered the morphology more uniform. Compared to bare AZ31 magnesium (Mg) alloys (E corr = −1.462 ± 0.006 V, I corr = (4.8978 ± 0.2455) × 10 −6 A/cm 2 ), the corrosion current density of the HA/TA-coated magnesium alloys ((5.6494 ± 0.3187) × 10 −8 A/cm 2 ) decreased two orders of magnitude, and the corrosion potential of the HA/TA-coated Mg alloys (E corr = −1.304 ± 0.006 V) increased by about 158 mV. This indicated that the HA/TA coating was effectively protecting the AZ31 against corrosion in simulated body fluid (SBF). Cell proliferation assays and cell morphology observations results showed that the HA/TA coating was not toxic to the MC3T3-E1 cells.