Air quality is an important factor in maintaining human health and environmental sustainability. Increasing transportation activity in Pati Regency contributes to higher air-pollutant emissions. This study develops a real-time air-quality monitoring and classification system using the K-Nearest Neighbors (KNN) algorithm. The system uses MQ-7, MQ-135, and SDS011 sensors to measure CO, CO₂, PM2.5, and PM10 concentrations. Measurement data are transmitted to Firebase Realtime Database and classified through a graphical user interface using Euclidean distance. Experimental results show that the system achieves 83% accuracy, 85% precision, 83% recall, and an F1-score of 82%. These results indicate that the proposed system can provide reliable real-time air-quality information for environmental monitoring applications.