This study utilized the random forest machine learning technique to investigate predictors of overall happiness in elementary and middle school students and compared differences between age groups. Using longitudinal data from the 2020 and 2022 Korean Children’s Panel Survey (PSKC), predictive models were built and the importance of various child and parent factors was analyzed. The results showed that elementary students’ happiness was rated at 90.0%, while the corresponding rating for middle school students was 85.7%, indicating higher happiness among younger students. To predict overall happiness, one model for elementary students and three for middle school students (single-time-point, delta, and time-weighted) were compared. Across all models, school adaptation and self-esteem were significant predictors. However, key predictors differed by age. For elementary students, a sense of community and peer attachment were important. In contrast, the single-time-point model for middle school students emphasized executive function difficulties and sleep duration. The delta model highlighted changes in school change, while the time-weighted model showed greater influence from peer attachment and various parent factors. Overall, this study demonstrates the usefulness of machine learning in predicting student happiness and highlights the need for tailored, age-specific interventions for educational and developmental policy planning in future research.