This study discusses the optimization of the K-Nearest Neighbor (KNN) algorithm using Genetic Algorithm (GA) in detecting diabetes mellitus. The research includes stages of collecting datasets on diabetes mellitus symptoms, data preprocessing through normalization and dataset alignment, model implementation, and testing with various scenarios to achieve the highest accuracy. The data used consists of the Pima Indians Diabetes Database as dataset 1 and the Early Stage Diabetes Risk Prediction Dataset as dataset 2. The evaluation is conducted by comparing the accuracy results between KNN without optimization and KNN optimized using Genetic Algorithm. The study's results indicate that optimization is performed by finding the optimal combination of the k-value and the features used in classification. The Genetic Algorithm produces individuals with the best fitness based on the combination of k-values and features that yield the highest accuracy. Testing was conducted on two datasets with two different fold values. The best accuracy was obtained in the 10-fold test, where the accuracy for dataset 1 increased from 74.2% to 79.1% after optimization. Meanwhile, for dataset 2, the accuracy improved from 97.5% to 98.2% after optimization. There was an increase in accuracy for dataset 1, whereas for dataset 2, the improvement was not significant. The conclusion of this study is that optimizing the KNN algorithm using Genetic Algorithm has proven to enhance the accuracy of diabetes mellitus detection, especially in numerical datasets with more complex features.