We use a complete sample of galaxies drawn from the Sloan Digital Sky Survey to study how structure, star formation and nuclear activity depend on local density and on stellar mass. Local density is estimated by counting galaxies above a fixed absolute magnitude limit within cylinders 2 Mpc in projected radius and ±500 km s−1 in depth. The stellar mass distribution of galaxies shifts by almost a factor of two towards higher masses between low- and high-density regions. At fixed stellar mass both star formation and nuclear activity depend strongly on local density, while structural parameters such as size and concentration are almost independent of it. Only for low-mass galaxies (M* < 3 × 1010 M⊙, where M*= stellar mass) do we find a weak shift towards greater concentration and compactness in the highest-density regions. The galaxy property most sensitive to environment is specific star formation rate (SFR). For galaxies with stellar masses in the range 1010–3 × 1010 M⊙, the median SFR/M* decreases by more than a factor of 10 as the population shifts from predominantly star-forming at low densities to predominantly inactive at high densities. This decrease is less marked, but still significant, for high-mass galaxies. Galaxy properties that are associated with star formation correlate strongly with local density. At fixed stellar mass twice as many galaxies host active galactic nuclei (AGNs) with strong [O iii] emission in low-density regions as in high. Massive galaxies in low-density environments also contain more dust. To gain insight into the processes that shut down star formation, we analyse correlations between spectroscopic indicators that probe the star formation history (SFH) on different time-scales: the λ4000 break strength, the Balmer-absorption index HδA, and the specific SFR/M*. The correlations between these indicators do not depend on environment, suggesting that the decrease in star formation activity in dense environments occurs over long (>1-Gyr) time-scales. Since structure does not depend on environment for galaxies with masses greater than 3 × 1010 M⊙, the trends in recent SFH, dust and nuclear activity in these systems cannot be driven by processes that alter structure, for example mergers or harassment. The SFH–density correlation is strongest for small-scale estimates of local density. We see no evidence that star formation history depends on environment more than 1 Mpc from a galaxy. Finally, we highlight a striking similarity between the changes in the galaxy population as a function of density and as a function of redshift. We use mock catalogues derived from N-body simulations to explain how this may be understood.