Magnesium alloys are potential in biomedical materials, but their corrosion rates are high in human body fluid so that they can not be used enough time. Therefore, to improve the anti-corrosion property of the alloys is important for their application in biomedical materials. In the work, a new coating was prepared from poly (3-hydroxybutyrate) (PHB), a biopolymer used as a sustained release carrier of drugs. The effect of the PHB coating was studied by electrochemical tests, scanning electron microscope (SEM) and weight loss corresponding with the corrosion time. The result showed the sample coating PHB have a higher corrosion potential than one before coating PHB, that is, PHB coating is effective for improvement of corrosion resistant of the alloy. Moreover, the corrosion state on the surface is even by SEM, implied the corrosion rate of the PHB coating is divinable and controllable. Whereby, PHB should be suitable for anti-corrosion of magnesium alloys applying in biomedical materials.