Theoretical models of compaction and porosity modification in sandstones during burial are discussed. Theory predicts that mechanical compaction is the dominant porosity reducing mechanism during burial from 0 to 2.5-3 km. Porosity-depth trends are at this stage mainly controlled by the stability of the grain framework and the effective stress. Time and temperature also influence the porosity-depth gradients at shallow to moderate depths, but are probably less important than effective stress and framework grain composition. At greater burial depths, below 2.5-3 km, chemical compaction, including pressure solution, can explain most of the porosity reduction in well sorted clean arenites. Theoretical modelling of the intergranular pressure solution suggests that sandstones may lose porosity rapidly by this mechanism below 2.5-3 km and that factors capable of retarding pressure solution and quartz cementation are required to maintain prospective porosities below 4 km. This theory and comparisons with empirical data from Jurassic sandstones from offshore Norway indicate that high porosity is favoured by (1) overpressures approaching the lithostatic pressure gradient, (2) a short residence time below 3 km burial, (3) coatings on grains, of clay or microcrystalline quartz which prevent quartz dissolution and precipitation and (4) a high content of feldspar and early diagenetic secondary pores. Early hydrocarbon emplacement may retard quartz cementation and preserve porosity, but chemical compaction probably continues after oil emplacement, except at very high hydrocarbon saturations.