Cleanliness and microstructure significantly impact the magnetic properties of soft magnetic materials. This study investigates the impact of Mg treatment on the cleanliness, microstructure, and magnetic properties of Fe–80Ni alloy. The content of Mg ranges from 0% to 0.034%. The O and S contents can be reduced to 0.0006% and 0.0011%, respectively, when the content of Mg is 0.027%, and the number of inclusions is reduced. Simultaneously, the primary inclusions are modified to Mg‐containing inclusions. Based on electron backscattered diffraction results, Mg treatment can refine the deformed grain and enhance grain boundary energy after cold rolling. In addition, the grains exhibit enhanced growth after annealing with Mg treatment. Due to the improvement of cleanliness and microstructure, the magnetic properties of Fe–80Ni alloy are enhanced with Mg treatment. With Mg treatment, the coercivity of alloys is reduced, and maximum magnetic susceptibility (χmax) increases to 0.3247 with Mg treatment, while that is 0.1938 without Mg treatment.