Objective Prolonged mechanical ventilation after cardiac surgery contributes significantly to morbidity, mortality, and excessive hospital resource use. Accurate prediction of prolonged mechanical ventilation duration can improve decision-making and patient outcomes. We aimed to develop and validate time-to-event models to predict the duration of ventilation and prolonged mechanical ventilation. Methods From the Medical Information Mart for Intensive Care III and IV databases, we extracted postoperative data from all cardiac surgery patients. We benchmarked 3 machine learning time-to-event algorithms (random survival forest, gradient boosted survival model, and survival support vector machine) against traditional Elastic-Net Cox regression. We evaluated model performance using weighted mean area under the curve (AUC¯wC,D), cumulative/dynamic area under the receiver operating characteristic curve (AUCC,D(t)), Concordance Index, and integrated Brier score. Permutation feature importance was reported for the best models. We conducted a sensitivity analysis to evaluate model fairness across different races and sexes. Results Models were trained on data from 10,430 cardiac surgery patients ventilated for a median of 7.0 hours (interquartile range, 4.4-16.0). Random survival forest had the highest AUC¯wC,D (0.834, 95% CI, 0.832-0.836) and integrated Brier score (0.041), whereas gradient boosted survival model had the highest Concordance Index (0.721, 95% CI, 0.717-0.724). All machine learning models significantly outperformed Elastic-Net Cox Regression. Ventilatory settings, laboratory results, and Sequential Organ Failure Assessment score within 4 hours of intubation were identified as the most important features. Sensitivity analysis showed equal or improved performance for minority female and non-White cohorts. Conclusions Machine learning time-to-event models for prolonged mechanical ventilation and the duration of ventilation, particularly random survival forest and gradient boosted survival model, have significantly improved performance compared with current state-of-the-art tools and may be valuable decision supports in the postoperative management of cardiac surgery patients.