Pneumocystis jirovecii pneumonia (PJP) is a life-threatening infection with high mortality especially in immunocompromised patients such as HIV patients. The study investigated the prognostic value of neutrophil-to-lymphocyte ratio (NLR), monocyte-to-lymphocyte ratio (MLR), and platelet-to-lymphocyte ratio (PLR) in patients with PJP. Post-diagnosis trajectories of these ratios were analyzed using group trajectory modeling. Three NLR trajectories were identified: continuously decreasing (15%), stable (68%), and continuously increasing (17%). Patients with continuously decreasing NLR had a significantly lower 28-day survival (P < 0.05). Log-transformed NLR (logNLR) trajectory was an independent prognostic factor, while logMLR and logPLR were not significantly associated with outcomes. A persistently decreasing logNLR predicts a poor prognosis and serves for early risk stratification.