This study presents a data-driven approach for classifying food safety alerts related to chemical and microbial contaminants in dairy products using the Rapid Alert System for Food and Feed (RASFF) and the World Health Organization (WHO)’s Global Environmental Monitoring System (GEMS) food contaminants databases. This research aimed to prioritise microbial and chemical hazards based on their presence and severity through exploratory data analysis and to classify the severity of chemical hazards using machine learning (ML) approaches. It identified Listeria monocytogenes, Escherichia coli, Salmonella, Pseudomonas spp., Staphylococcus spp., Bacillus cereus, Clostridium spp., and Cronobacter sakazakii as the microbial hazards of priority in dairy products. The study also prioritised the top ten chemical hazards based on their presence and severity. These hazards include nitrate, nitrite, ergocornine, 3-MCPD ester, lead, arsenic, ochratoxin A, cadmium, mercury, and aflatoxin (G1, B1, G2, B2, G5 and M1). Using ML techniques, the accuracy rate of classifying food safety alerts as either ‘serious’ or ‘non-serious’ was up to 98 %. Additionally, the study identified Reference dose (RfD), substance amount, notification type, product, and substance as the most important features affecting the ML models’ performance. These ML models (decision trees, random forests, k-nearest neighbors, linear discriminant analysis, and support vector machines) were also validated on an external dataset of RASFF alerts related to chemical contaminants in dairy products. They achieved an accuracy of up to 95.1 %. The study’s findings demonstrate the models’ robustness and ability to classify food safety alerts related to chemical contaminants in dairy products, even on new data. These results can enhance the development of more effective machine-learning models for classifying food safety alerts related to chemical contaminants in dairy products, highlighting the importance of developing accurate and efficient classification models for timely intervention.