Air pollution is increasing profusely in Indian cities as well as throughout the world, and it poses a major threat to climate as well as the health of all living things. Air pollution is the reason behind degraded indoor air quality (IAQ) in urban buildings. Carbon dioxide (CO2) is the main contributor to indoor pollution as humans themselves are one of the generating sources of this pollutant. The testing and monitoring of CO2 consume cost and time and require smart sensors. Thus, to solve these limitations, machine learning (ML) has been used to predict the concentration of CO2 inside an office room. This study is based on the data collected through real-time measurements of indoor CO2, number of occupants, area per person, outdoor temperature, outer wind speed, relative humidity, and air quality index used as input parameters. In this study, ten algorithms, namely, artificial neural network (ANN), support vector machine (SVM), decision tree (DT), Gaussian process regression (GPR), linear regression (LR), ensemble learning (EL), optimized GPR, optimized EL, optimized DT, and optimized SVM, were used to predict the concentration of CO2. It has been found that the optimized GPR model performs better than other selected models in terms of prediction accuracy. The result of this study indicated that the optimized GPR model can predict the concentration of CO2 with the highest prediction accuracy having R , RMSE, MAE, NS, and a20-index values of 0.98874, 4.20068 ppm, 3.35098 ppm, 0.9817, and 1, respectively. This study can be utilized by the designers, researchers, healthcare professionals, and smart city developers to analyse the indoor air quality for designing air ventilation systems and monitoring CO2 level inside the buildings.