This paper was targeted on achieving in-cycle real-time prediction of NOx emission of diesel engines in both steady-state and transient processes based on cylinder pressure. Specifically, input parameters of the NOx emission model were determined, an offline empirical model of NOx emission was built based on steady-state test data, and in-cycle real-time prediction of NOx emission was achieved in the in-cylinder combustion analysis tool.Based on the mechanism of NOx formation, combustion state parameters in strong correlation with NOx emission were extracted from cylinder pressure, rate of cylinder pressure, rate of heat release, accumulated heat release and burned zone temperature. Quantitative correlations between combustion state parameters and NOx emission were calculated based on steady-state test data and the inputs of the empirical model of NOx emission were determined. The quadratic polynomial model from combustion state parameters to NOx emission was built based on steady-state test data. The combustion state parameters and quadratic polynomial model functions were added in the in-cylinder combustion analysis tool, which was developed based on MPC5644A MCU. NOx emission measured from test data and predicted from in-cylinder combustion analysis tool were compared under both steady-state and transient processes, and the accuracy of in-cycle real-time prediction of NOx emission was verified. Under steady-state operating conditions: except for one bad condition, relative errors of the other 15 conditions were all less than 10% ; average relative error of the 16 conditions was 6.8%. Under transient operating conditions, the prediction accuracy of NOx emission was slightly worse.