Computational fluid dynamics (CFD) models based on the turbulent mixture multiphase model were applied to consider the effect of cavitation on the spray of diesel fuel. The effects of injection pressure and length‐to‐width (L/W) ratio on the velocity distribution, cavitation number, discharged coefficient, and nozzle exit velocity were investigated and the performance of the model was compared with the experimental data. The results indicate that the cavitation generated in the nozzle has a strong impact on the fuel injection and spray quality, whereas the L/W ratio is a highly effective parameter for cavitation behavior. In addition, by increasing the L/W ratio, the range of cavitation number, wall friction, and flow resistance increase but in the cavitation region the velocity profile in radial and axial directions, spray cone angle, nozzle exit velocity, and the discharged coefficient decrease.