Functionalisation of single-walled carbon nanotubes (SWNTs) with atoms and molecules has the potential to prepare charge–transfer complexes for numerous applications. Here, we used density functional theory with dispersion correction (DFT + D) to examine the encapsulation and adsorption efficacy of single-walled carbon nanotubes to trap halogens. Our calculations show that encapsulation is exoergic with respect to gas-phase atoms. The stability of atoms inside SWNTs is revealed by the charge transfer between nanotubes and halogens. Encapsulation of halogens in the form of diatomic molecules is favourable with respect to both atoms and diatomic molecules as reference states. The adsorption of halogens on the outer surfaces of SWNTs is also exothermic. In all cases, the degree of encapsulation, adsorption, and charge transfer is reflected by the electronegativity of halogens.