Objective By blending hydrogen to natural gas pipelines,long-distance,large-scale,and low-cost transportation of hydrogen can be achieved,but it also brings a series of problems.Considering the impact of the hydrogen blending ratio on compressor performance,pipeline energy consumption,and carbon emissions,this paper innovatively proposes an optimization model for energy consumption and carbon emissions of the hydrogen-blended natural gas pipeline and makes a comprehensive analysis of the station operation mode.Methods Based on the characteristics of the model,the IRIME algorithm is proposed and compared with other algorithms.It was found that the IRIME algorithm has higher convergence speed and higher convergence accuracy.Results Taking a specific gas pipeline as an example,the IRIME algorithm was used to solve the model.The results showed that the total energy consumption and total carbon emissions were reduced compared with actual operating conditions.The outlet pressure and outlet temperature increased after hydrogen blending compared with the operating conditions without hydrogen blending;and pressure drop,efficiency of the fuel-driven compressor unit,efficiency of the electric-driven compressor unit,average efficiency of the compressor unit,natural gas carbon emissions,electric energy carbon emissions,total carbon emissions,power consumption,gas consumption,and total energy consumption all decreased.Conclusion Compared with no hydrogen blending,when the hydrogen blending ratio is 5%,10%,15%,and 20%,the total energy consumption is reduced by 2.00%,4.70%,7.00%,and 9.83%,and the total carbon emissions are reduced by 2.99%,5.36%,8.32%,and 10.68%,which has certain guiding significance for on-site operation.