The invention relates to a magnetic fluorescent coding microsphere and a preparation method thereof. Firstly, during magnetic particle synthesis, medium-chain and short-chain fatty acids are used formodifying the surfaces of magnetic nanoparticles, so that the polarity of the surfaces of the magnetic nanoparticles is increased, the magnetic nanoparticles can be uniformly dispersed in a good solvent, and the particle size is more uniform; then, a two-step swelling method is adopted, which comprises the following steps: firstly, enabling magnetic nanoparticles to enter swelled polymer microspheres; enabling the fluorescent dye to enter the swollen polymer microspheres to form a 'magnetic particle core-fluorescent shell layer' structure, and reducing quenching and shielding effects of the magnetic particles on fluorescence to the greatest extent; then, by utilizing the swelling fading effect of the microspheres in a poor solvent, sealing cracks generated on the surfaces of the microspheres due to the swelling effect, avoiding leakage of magnetic nanoparticles and fluorescent dyes, greatly simplifying the sealing process, and obtaining the magnetic fluorescent coding microspheres withgood microsphere particle uniformity, good magnetic performance and good fluorescent performance.