The variation of porosity in quartzose sandstones is calculated as a function of depth, temperature gradient, burial rate, stylolite frequency, and hydrocarbon saturation. Calculations were performed by considering the effects of both mechanical compaction and chemical compaction/cementation. This latter process dominates at temperatures greater than approximately 90 degrees C and is due to quartz redistribution within the sandstone. Quartz redistribution stems from clay-induced quartz dissolution at stylolite interfaces, coupled with diffusional transport of aqueous silica into the interstylolite sandstone and precipitation on quartz surfaces as cement. Many model parameters are obtained from theoretical calculations or laboratory measurements, and few basin-dependent parameters are required to make porosity predictions. A set of porosity predictions is presented in porosity/depth figures. Close correspondence between computed results and measured porosities in cores from a variety of sedimentary basins demonstrates the accuracy of the predictions.