Due to its exceptional qualities, ultra-high-performance concrete (UHPC) has recently become one of the hottest research areas, although the material’s significant carbon emissions go against the current development trend. In order to lower the carbon emissions of UHPC, this study suggests a machine learning-based strategy for optimizing the mix proportion of UHPC. To accomplish this, an artificial neural network (ANN) is initially applied to develop a prediction model for the compressive strength and slump flow of UHPC. Then, a genetic algorithm (GA) is employed to reduce the carbon emissions of UHPC while taking into account the strength, slump flow, component content, component proportion, and absolute volume of UHPC as constraint conditions. The outcome is then supported by the results of the experiments. In comparison to the experimental results, the research findings show that the ANN model has excellent prediction accuracy with an error of less than 10%. The carbon emissions of UHPC are decreased to 688 kg/m3 after GA optimization, and the effect of optimization is substantial. The machine learning (ML) model can provide theoretical support for the optimization of various aspects of UHPC.