The ultrahigh-resolution mass spectrometry (UHR-MS) coupled with isotope labeling is of increasing attentions in elucidating the transform mechanisms of dissolved organic matter (DOM).However, there is a paucity of automated formula assignment algorithm applicable to halogenated disinfection byproducts (Xn-DBPs), particurally for iodinated organic compounds, and deuterated DOM . Herein, for the first time, we have developed a novel formula assignment algorithm based on deuterium-labeled UHR-MS, namely FTMSDeu, and the algorithm was applied to determine precursor molecules of Xn-DBPs and evaluate the relative contribution of electrophilic addition and electrophilic substitution reactions in Xn-DBPs formation according to the hydrogen/deuterium exchange of DOM molecules. Furthermore, tandem mass spectrometry with homologous-based network analysis was employed to validate the formula assignment accuracy (41%) of FTMSDeu for iodinated disinfection byproducts (In-DBPs). And the remaining In-DBPs compounds were assigned with the empirical rule of minimum number of non-oxygen heteratoms.The electrophilic substitution accounted for 82%-98%, 71%-89%, and 43%-45% of Xn-DBPs formation for Xn-DBPs containing chlorine, bromine, and iodine, respectively, manifesting the dominant role of electrophilic substitution in chlorine disinfection under conditions of low bromine and iodine concentrations. The absence of presumed Xn-DBPs precursors in some treatments in this study also suggests that Xn-DBPs formation include secondary reactions (e.g., oxidation, hydrolysis) in addition to electrophilic addition and/or substitution of halogens. These findings highlight the significance of isotopically labeled UHR-MS techniques in revealing the transformation of DOM in natural and engineered systems.