The purity of drinking water is an important issue of the human life quality. Water disinfection has saved millions people from the diseases spread with water. However, that procedure has a certain drawback due to formation of toxic organic disinfection products. Establishing the structures of these products and the mechanisms of their formation and diminishing their levels in drinking water represent an important task for chemistry and medicine, while mass spectrometry is the most efficient tool for the corresponding studies. The current review throws light upon natural and anthropogenic sources of the formation of disinfection by-products (DBPs) and the mechanisms of their formation related to the structural peculiarities and the presence of functional groups. In addition to chlorination, bromination is discussed since it is used quite often as an alternative method of disinfection, particularly, for the purification of swimming pool water. The benefits of the contemporary GC/MS and LC/MS methods for the elucidation of DBP structures and study of the mechanisms of their formation are discussed. The reactions characteristic for various functional groups and directions of transformation of certain classes of organic compounds in conditions of aqueous chlorination/bromination are also covered in the review.