Structure, stability, electronic structure, spectroscopy and chemical bonding properties of a fluorine atom doped gas-phase small to medium-sized magnesium clusters, FMg
n
(n = 2–20), systematically investigated by CALYPSO software together with density functional theory (DFT). Structural calculations showed that FMg
n
has a structural diversity which is rarely reported in other magnesium-based clusters before. F atoms were always located in the outer layer of the Mg
n
host clusters and only two or three Mg atoms surround it. FMg
18
was revealed to be supposed to have robust relative stability. Charge transfer and density of states were calculated for analyzing the electronic structure characteristics. Theoretical calculations of IR, Raman and UV–Vis spectra were computed to provide data guidelines for future experimental observations. Finally, the F–Mg and Mg–Mg chemical bonds of the FMg
n
clusters were analyzed, including the critical bonding points (BCPs) of Laplacian of electron density (Δρ), electron localization function (ELF) and interaction region indicator (IRI). The kind and strength of chemical bonds reveal the mechanism by which the F atom was rapidly stabilized by Mg
n
(n = 2–20) host clusters.