BACKGROUND: Extended postoperative hospital stays are associated with numerous clinical risks and increased economic cost. Accurate preoperative prediction of extended length of stay (LOS) can facilitate targeted interventions to mitigate clinical harm and resource utilization. OBJECTIVE: To develop a machine learning algorithm aimed at predicting extended LOS after cervical spine surgery on a national level and elucidate drivers of prediction. METHODS: Electronic medical records from a large, urban academic medical center were retrospectively examined to identify patients who underwent cervical spine fusion surgeries between 2008 and 2019 for machine learning algorithm development and in-sample validation. The National Inpatient Sample database was queried to identify cervical spine fusion surgeries between 2009 and 2017 for out-of-sample validation of algorithm performance. Gradient-boosted trees predicted LOS and efficacy was assessed using the area under the receiver operating characteristic curve (AUROC). Shapley values were calculated to characterize preoperative risk factors for extended LOS and explain algorithm predictions. RESULTS: Gradient-boosted trees accurately predicted extended LOS across cohorts, achieving an AUROC of 0.87 (SD = 0.01) on the single-center validation set and an AUROC of 0.84 (SD = 0.00) on the nationwide National Inpatient Sample data set. Anterior approach only, elective admission status, age, and total number of Elixhauser comorbidities were important predictors that affected the likelihood of prolonged LOS. CONCLUSION: Machine learning algorithms accurately predict extended LOS across single-center and national patient cohorts and characterize key preoperative drivers of increased LOS after cervical spine surgery.