Purpose: This study aims to optimize the determination of the optimal number of clusters in the segmentation of handicraft-based Micro, Small, and Medium Enterprises (MSMEs) in Yogyakarta to support targeted and data-driven development strategies. Approach: A quantitative approach was applied to survey data collected from 145 MSMEs. The analytical pipeline consisted of four stages: (1) data acquisition through structured surveys, (2) preprocessing including encoding, mode imputation for missing values, and Min–Max normalization, (3) model development using the K-Means algorithm integrated with Particle Swarm Optimization (PSO) to automatically search for the optimal cluster number (K = 2–10), and (4) performance evaluation using Silhouette Score, Sum of Squared Error (SSE), and Mean Absolute Error (MAE). Result: The optimization process consistently converged to an optimal configuration of K = 8 clusters. Compared to standard K-Means, the proposed K-Means + PSO model reduced SSE from 54.555 to 51.676 and MAE from 0.124 to 0.116, indicating improved clustering stability and compactness. Semantic centroid analysis further revealed a hierarchical MSME structure consisting of Established Digital Adopters, Developing Potential Enterprises, and Subsistence Micro Enterprises, highlighting disparities in digital maturity and market reach. Novelty: This study contributes by integrating swarm-based optimization with centroid-driven semantic profiling, bridging algorithmic enhancement and policy-relevant interpretation. The proposed framework provides a robust and interpretable clustering model for MSME segmentation in emerging economic contexts.