Uncontrolled growth of dendrites in lithium metal batteries (LMBs) permeates into the separator and reaches the cathode, causing an internal short circuit and eventually leading to serious safety accidents. Herein, we design an in situ formed Li–Sn alloy layer via RF magnetron sputtering on a commercial separator facing the lithium metal side. The Li–Sn alloy layer is beneficial to guide the deposition and dendrite growth of lithium on the side of the separator due to its fast Li+ diffusion kinetics, which will induce lateral instead of vertical growth of dendrites when the dendrites on both sides meet each other, to protect the separator from being pierced. With the above effect of the Li–Sn alloy, all the Li‖Cu cells, Li‖Li cells and Li‖LFP full cells deliver improved electrochemical performance. Different from the methods of inhibiting dendrites, the Li–Sn alloy layer changes the growth direction of dendrites, and this induction strategy is thermodynamically advantageous. Moreover, this facile preparation process has potential applications to easily realize large-scale production, thus accelerating the application of LMBs.