With the increasing requirements for clean and effective utilization, coal swelling pretreatment provides a good theoretical basis for coal molecular structure, application in coal pyrolysis, and liquefaction. Ionic liquids containing magnetic anionic groups were designed, synthesized, and used as solvents to study the effect on swelling pyrolysis performance. Studies have shown magnetism enhancement with the growth of alkyl chains. The growth of the MIL alkyl side chain made the modification effect of coal more obvious, and the swelling degree showed a trend of first increasing and then decreasing with the increase of temperature and time, and at the temperature of 35 °C, the swelling degree is the largest when the modification time is 8 h. Pyrolysis experiments show that magnetic ionic liquid (MIL) pretreatment can significantly reduce the temperature at the maximum weight loss of coal and increase the tar content of pyrolysis, indicating that MIL plays a catalytic cracking role in coal pyrolysis.