Patients with diabetes mellitus (DM) are twice as likely as nondiabetic individuals to develop depression, which is a prevalent but often undiagnosed psychiatric comorbidity. Patients with DM who are depressed have poor glycemic control, worse quality of life, increased risk of diabetic complications, and higher mortality rate. The present study aimed to develop machine learning (ML) models that identify depression in patients with DM, determine the best performing model by evaluating multiple ML algorithms, and investigate features related to depression. We developed six ML models, including random forest, K-nearest neighbor, support vector machine (SVM), Adaptive Boosting, light gradient-boosting machine, and Extreme Gradient Boosting, based on the Korea National Health and Nutrition Examination Survey. The results showed that the SVM model performed well, with a cross-validated area under the receiver operating characteristic curve of 0.835 (95% confidence interval [CI] = 0.730–0.901). Thirteen features were related to depression in patients with DM. Permutation feature importance showed that the most important feature was subjective health status, followed by level of general stress awareness; stress recognition rate; average monthly income; triglyceride (mg/dL) level; activity restriction status; European quality of life (EuroQoL): usual activity and lying in a sickbed in the past 1 month; EuroQoL: pain / discomfort, self-care, and physical discomfort in the last 2 weeks; and EuroQoL: mobility and chewing problems. The current findings may offer clinicians a better understanding of the relationship between DM and depression using ML approaches and may be an initial step toward developing a more predictive model for the early detection of depressive symptoms in patients with DM.