This study aimed to create machine learning-based screening tools for middle school students to predict suicide planning or attempts in school settings, and to identify the risk factors. A total of 3,812 records from a national database established through rigorous sampling designs, the 2022 Korean Youth Risk Behavior Web-based Survey (KYRBWS), were used to ensure high generalizability and minimize bias of the study’s outcomes. Five machine-learning models, utilizing various algorithms available in SAS or Python, underwent training with a 10-fold validation process. Performance evaluation included metrics such as accuracy, sensitivity, specificity, and AUC, resulting from using a common unseen test dataset. Feature importance was interpreted through the average absolute values of Shapley additive explanations (SHAP) as well as the standardized regression coefficients. The artificial neural-network model with three hidden layers and dropout layers between each dense layer emerged as the top performer. It achieved sensitivity and AUC exceeding 91%, with accuracy and specificity at 86%. However, all five models, utilizing an optimal set of nine features, demonstrated strong performance. Mental health features such as suicidal thoughts, feeling lonely, or feeling sad, and the subjective perception of dental health emerged as significant risk factors. Adolescents considering suicide were approximately 12.7 times more likely to make plans or attempt suicide than their peers without such ideation (OR = 12.7; 95% CI = [8.0-20.1]). Individuals perceiving dental health as 'Very bad' were 4.4 times more prone to suicidal behavior than those with 'Average' ratings (OR = 4.4; 95% CI = [1.4-13.5]). Those always feeling lonely were 2.8 times more likely to engage in suicidal behavior (OR = 2.8; 95% CI = [1.1-7.1]), while persistent feelings of sadness increased the likelihood by 1.8 times (OR = 1.8; 95% CI = [1.2-2.8]). The study also offers valuable guidance on algorithm selection and suitable options for similar applications.