In this article, the electrochemical method of preparing Mg–Li–Sm alloys by codeposition in LiCl–KCl–MgCl2–SmCl3 melts was investigated. Transient electrochemical techniques, such as cyclic voltammetry, chronopotentiometry, and chronoamperometry were used to explore the electrochemical formation of Mg–Li–Sm alloys. Chronopotentiograms demonstrated that the codepositon of Mg, Li, and Sm occurred when current densities were more negative than −0.31 A cm−2. Chronoamperograms indicated that the onset potential for the codeposition of Mg, Li, and Sm was −2.40 V, and the codeposition of Mg, Li, and Sm was formed when the applied potentials were more negative than −2.40 V. The different phases of Mg–Li–Sm alloys were prepared by galvanostatic electrolysis and characterized by X–ray diffraction (XRD), optical microscope (OM), and scanning electron microscopy (SEM). An inductively coupled plasma (ICP) analysis showed that the lithium and samarium contents in Mg–Li–Sm alloys could be controlled by the concentrations of MgCl2 and SmCl3. The results demonstrated that Sm could refine the grains dramatically. When the Sm content was 0.8 wt pct, the grain size was the finest.