Context. The TRAPPIST-1 system is an iconic planetary system in various aspects (e.g., habitability, resonant relation, and multiplicity) and hence has attracted considerable attention. The mass distribution of the TRAPPIST-1 planets is characterized by two features: the two inner planets are large, and the masses of the four planets in the outer orbit increase with orbital distance. The origin of these features cannot be explained by previous formation models. Aims. We investigate whether the mass distribution of the TRAPPIST-1 system can be reproduced by a planet formation model using N-body simulations. Methods. We used a gas disk evolution model around a low-mass star constructed by considering disk winds and followed the growth and orbital migration from planetary embryos with the isolation mass, which increases with orbital distance.Results. As a result, we find that from the initial phase, planets in inner orbits undergo rapid orbital migration, and the coalescence growth near the inner disk edge is enhanced. This allows the inner planets to grow larger. Meanwhile, compared with the inner planets, planets in outer orbits migrate more slowly and do not frequently collide with neighboring planets. Therefore, the trend of increasing mass toward the outer orbit, called reversed mass ranking, is maintained. The final mass distribution approximately agrees with the two features of the mass distribution in the TRAPPIST-1 system. Conclusions. We discover that the mass distribution in the TRAPPIST-1 system can be reproduced when embryos experience rapid migration and become trapped near the disk inner edge, and then more massive embryos undergo slower migration. This migration transition can be achieved naturally in a disk evolution model with disk winds. Key words. planets and satellites: formation -planets and satellites: dynamical evolution and stability -planet-disk interactions -Protoplanetary disks c1.580 ± 0.013 1.308 ± 0.056 5.447 +0.222 −0.235 d 2.227 ± 0.019 0.388 ± 0.012 4.354 +0.156 −0.163 e 2.925 ± 0.025 0.692 ± 0.022 4.885 +0.168 −0.182 f 3.849 ± 0.033 1.039 ± 0.031 5.009 +0.138 −0.158 g 4.683 ± 0.040 1.321 ± 0.038 5.042 +0.136 −0.158 h 6.189 ± 0.053 0.326 ± 0.020 4.147 +0.322 −0.302 Notes. The second column, a, indicates the semimajor axis. Data are obtained from Agol et al. (2021).2018; Acuña et al. 2021). The estimates consistently indicate that all seven planets have rocky interiors with a small water mass fraction ( 10wt%). In particular, the water fraction of the three inner planets is near zero ( 10 −3 wt%). In addition, it has been reported that the densities of the planets can be described with a single mass-radius relation (Agol et al. 2021). The orbital configuration of the TRAPPIST-1 planets is also characteristic. The outer planets d-h are in first-order mean-motion resonancesArticle number, page 1 of 7