The IllustrisTNG project is a new suite of cosmological magneto-hydrodynamical simulations of galaxy formation performed with the Arepo code and updated models for feedback physics . Here we introduce the first two simulations of the series , TNG100 and TNG300 , and quantify the stellar mass content of about 4000 massive galaxy groups and clusters ( 10 ^ { 13 } \leq M _ { 200 c } / { M } _ { \odot } \leq 10 ^ { 15 } ) at recent times ( z \leq 1 ) . The richest clusters have half of their total stellar mass bound to satellite galaxies , with the other half being associated with the central galaxy and the diffuse intra-cluster light . Haloes more massive than about 5 \times 10 ^ { 14 } { M } _ { \odot } have more diffuse stellar mass outside 100 kpc than within 100 kpc , with power-law slopes of the radial mass density distribution as shallow as the dark matter ’ s ( -3.5 \la \alpha _ { 3 D } \la - 3 ) . Total halo mass is a very good predictor of stellar mass , and vice versa : at z = 0 , the 3D stellar mass measured within 30 kpc scales as \propto ( M _ { 500 c } ) ^ { 0.49 } with a \sim 0.12 dex scatter . This is possibly too steep in comparison to the available observational constraints , even though the abundance of TNG less massive galaxies ( \la 10 ^ { 11 } { M } _ { \odot } in stars ) is in good agreement with the measured galaxy stellar mass functions at recent epochs . The 3D sizes of massive galaxies fall too on a tight ( \sim 0.16 dex scatter ) power-law relation with halo mass , with r ^ { stars } _ { 0.5 } \propto ( M _ { 200 c } ) ^ { 0.53 } . Even more fundamentally , halo mass alone is a good predictor for the whole stellar mass profiles beyond the inner few kpc , and we show how on average these can be precisely recovered given a single mass measurement of the galaxy or its halo .