Contemporary global policy, driven by concern for the environment, imposes increasingly stringent goals for reducing CO2 emissions. Therefore, there is an urgent need to develop effective models that allow an accurate prediction of CO2 emissions from vehicles powered by alternative fuels such as CNG. This article presents the process of creating one of the first models of CO2 emission for a vehicle powered by CNG. Emission modelling is based on data obtained from chassis dynamometer tests and road tests using the portable emission measurement system (PEMS). CO2 emission modelling was conducted in Python programming language using the Optuna framework for the XGBoost technique. The models obtained were validated, with indicators R2 0.9 and RMSE 0.49 for data from chassis dynamometer tests, and R2 0.7, RMSE 0.71 for road test data. This work has the potential to be used by transportation decision makers involved in environmental analyses and policymaking for urban areas.