With the rapid development of the Chinese electrified railway, the grid-connection-related issues in the railway power system (RPS) have become more and more prominent. To deal with those issues, various schemes, e.g., LC branches, static var compensator (SVC), and static synchronous compensator (STATCOM), are employed in the early days; however, they are not satisfactory enough from the perspective of either compensation performance or economic. The railway power flow controller (RPFC) has proven to be an effective route to deal with almost all grid-connection-related issues, while the needed large design capacity hinders its further commercialization. Many works were presented to cut down the design capacity of RPFC; however, most of them only focus on the traction mode of locomotives, which makes them lack generality and cannot be applied to the situation where regenerative braking energy (RBE) exists. To fill this gap, this paper proposes a flexible power assignment method for RPFC, in which the regenerative braking energy (RBE) is considered. The proposed method aims at reducing the converters’ design capacity under the premise that the concerned system can meet the grid-connection indexes, and it can be used both in the planning and real-time control stages. Firstly, the mathematical model of an RPFC-integrated RPS adopting the V/v transformer is derived, and the relationship between RPFC’s compensated power and the primary power factors (PFs) is revealed. Then, considering RBE, 16 compensation modes are developed based on the alternative positive or negative values exist in the primary PF angles, and the interaction mechanisms of primary PFs and Modes on RPFC’s compensated power are investigated. Based on the two-phase loads’ PF-P distribution, a precise load imitation is implemented to guide RPFC’s design and performance evaluation. Finally, under the premise of meeting the concerned grid-connection indexes, a flexible power assignment method is designed, in which RBE is embraced. The real measured data-based simulation shows that, the distribution of compensation modes drawn from two-phase synchronous measured data is highly similar to the one drawn from the proposed load imitation process, and these available candidates can be pre-embedded into the controller for real-time control. By adopting the proposed method, the rating of RPFC can be reduced by almost 50% compared to the conventional full compensation method (FCM) for the studied TSS. Besides, when the PF* is chosen in the interval of [0.9, 0.93], the rating decreasing ratio is maintained at over 50%. When PF* is chosen as 0.9, the negative sequence power in the concerned system can meet the standards, and for extreme situations, PF* can be selected higher in the interval of [0.9, 0.93], while more than 50% rating decreasing ratio can still be guaranteed. Besides, the proposed method can also lower the RPFC’s operating losses. Based on the testing experience of a real RPFC (10 MV·A), the daily operating losses can be evaluated, and the result indicates that by using the proposed method, the operating losses are cut down by almost 80%, which is quite considerable for long-term operation. The main contributions and conclusions are summarized as follows: (1) the designed flexible power assignment method is general and can be employed in the situation where RBE exists. Compared with the conventional FCM, the rating of RPFC can be reduced by almost 50%, and the negative sequence power of the concerned system can meet the grid-connection indexes; besides, the operating losses can be reduced by almost 80%. (2) With the consideration of RBE, the interaction mechanisms of primary PFs and the developed modes on RPFC’s compensated power are revealed. (3) Considering the intrinsic correlation between loads’ power and PF, the dynamic scanning method is designed to determine loads’ PF interval for every specific load power, by which the precise load imitation can be implemented for the guide of RPFC’s design. © 2023 Chinese Machine Press. All rights reserved.