Exploiting the capabilities of four different surveys – the Padova–Millennium Galaxy and Group Catalogue (PM2GC), the WIde-field Nearby Galaxy-cluster Survey (WINGS), the IMACS (Inamori-Magellan Areal Camera and Spectrograph) Cluster Building Survey (ICBS) and the ESO (European Southern Observatory) Distant Cluster Survey (EDisCS) – we analyse the galaxy stellar mass distribution as a function of local density in mass-limited samples, in the field and in clusters from low () to high () redshift. We find that at all redshifts and in all environments, local density plays a role in shaping the mass distribution. In the field, it regulates the shape of the mass function at any mass above the mass limits. In clusters, it seems to be important only at low masses ( in WINGS and in EDisCS), otherwise it seems not to influence the mass distribution. Putting together our results with those of Calvi et al. and Vulcani et al. for the global environment, we argue that at least at local density is more important than global environment in determining the galaxy stellar mass distribution, suggesting that galaxy properties are not much dependent on halo mass, but do depend on local scale processes.