Many types of bacteria form colonies that grow into physically robust and strongly adhesiveaggregates known as biofilms. A distinguishing characteristic of bacterial biofilms is an extracellular polymeric substance (EPS) matrix that encases the cells and provides physical integrity to the colony. The EPS matrix consists of a large amount of polysaccharide, as well as protein filaments, DNA and degraded cellular materials. The genetic pathways that control the transformation of a colony into a biofilm have been widely studied, and yield a spatiotemporal heterogeneity in EPS production. Spatial gradients in metabolites parallel this heterogeneity in EPS, but nutrient concentration as an underlying physiological initiator of EPS production has not been explored. Here, we study the role of nutrient depletion in EPS production in Bacillus subtilis biofilms. By monitoring simultaneously biofilm size and matrix production, we find that EPS production increases at a critical colony thickness that depends on the initial amount of carbon sources in the medium. Through studies of individual cells in liquid culture we find that EPS production can be triggered at the single-cell level by reducing nutrient concentration. To connect the single-cell assays with conditions in the biofilm, we calculate carbon concentration with a model for the reaction and diffusion of nutrients in the biofilm. This model predicts the relationship between the initial concentration of carbon and the thickness of the colony at the point of internal nutrient deprivation.