Long horizontal wells and large-scale volumetric fracturing are key technologies for shale oil development. Due to reservoir characteristics and the fracturing scale, the optimal length of horizontal wells varies in different fields. It is necessary to consider both reservoir flow and wellbore flow of long horizontal wells when the optimal length of horizontal wells is determined.North American marine shale has good continuity and is relatively homogeneous, with thick oil layers, where long horizontal wells play a decisive role in improving single-well oil production. In contrast, Chinese continental shale is highly heterogeneous, with rapid lateral changes and developed thin interbeds, and it requires the determination of reasonable lengths of horizontal wells to increase single-well oil production and economic benefits. Therefore, accurately characterizing shale oil reservoir flow and wellbore flow of long horizontal wells is crucial for the production capacity evaluation of shale oil and the determination of appropriate lengths of horizontal wells. This study, based on the five-zone linear flow, comprehensively considered the starting pressure gradient of the shale matrix, complex heterogeneous fracture networks, and stress sensitivity. It also established a multi-stage hydraulic fracture-wellbore coupled flow model of shale oil horizontal wells and solved the model using perturbation transformation and Laplace transformation. Based on this model, production capacity was evaluated and predicted, and complex fracture network parameter inversion was achieved. The influence of reservoir thickness and the number of fractures on the optimal length of shale oil horizontal wells was demonstrated. On this basis, a length optimization chart for shale oil horizontal wells was developed. The results show that the number of fractures is the main controlling factor affecting the optimal length of horizontal wells for thick shale. By applying the above model to actual fields, the study determined the optimal lengths of horizontal wells in different fields under current reservoir conditions. This research provides a theoretical basis for the determination of the optimal lengths of horizontal wells in different shale oil reservoirs.