The invention relates to a preparation method of esomeprazole magnesium, comprising the following steps: mixing omeprazole sulfide, diethyl tartrate and isopropyl titanate, adding diisopropylethylamine, stirring, Add cumene hydroperoxide dropwise, separate to obtain an oily substance; add strong base, stir, then add strong base one by one, extract, wash, do TLC monitoring, stop adding strong base when there is basically no spot; cool down, crystallize, Filter and rinse to obtain esomeprazole salt; dissolve esomeprazole salt in water, cool down to below 20°C, adjust pH, add magnesium sulfate heptahydrate aqueous solution dropwise, after the dropwise addition, stir and filter , rinse, and dry to obtain crude esomeprazole magnesium; dissolve the crude esomeprazole magnesium with methanol, decolorize activated carbon, filter, concentrate, dissolve again, add acetone aqueous solution, stir, suction filter, dry, The esomeprazole magnesium is obtained, and the product prepared by the invention has high purity, good yield and less impurities.