Magnesium metal as degradable metallic material is one of the most researched areas, but its rapid degradation rate restricts its development. The current anticorrosion surface modification methods require expensive equipment and complicated operation processes and cannot continue to introduce biofunction on modified surface. In this study, the GAHD conversion coatings were fabricated on the surface of magnesium alloys (MZM) by incubating in the mixture solution of gallic acid (GA) and hexamethylenediamine (HD) to decrease the corrosion rate and provide primary amines (-NH2), carboxyl (-COOH), and quinone groups, which is supposed to introduce biomolecules on MZM. Chemical structures of the MZM-GAHD and MZM-HEP-GAHD were explored by analyzing the results of FTIR and XPS comprehensively. Furthermore, it was proved that the heparin (HEP) molecules were successfully immobilized on MZM-GAHD surface through carbodiimide method. The evaluation of platelet adhesion and clotting time test showed that MZM-HEP-GAHD had higher anticoagulation than MZM-GAHD. Through electrochemical detection (polarization curves and electrochemical impedance spectroscopy Nyquist spectrum) and immersion test (Mg(2+) concentration and weight loss), it was proved that compared to MZM, both the MZM-GAHD and MZM-HEP-GAHD significantly improved the corrosion resistance. Finally, in vivo experimentation indicated that mass loss had no significant difference between MZM-1:1, MZM-HEP-1:1, and MZM. However, the trend still suggested that MZM-1:1 and MZM-HEP-1:1 possessed corrosion resistance property.