Many bacteria organize themselves into structurally complex communities known as biofilms in which the cells are held together by an extracellular matrix. In general, the amount of extracellular matrix is related to the robustness of the biofilm. Yet, the specific signals that regulate the synthesis of matrix remain poorly understood. Here we show that the matrix itself can be a cue that regulates the expression of the genes involved in matrix synthesis in Bacillus subtilis. The presence of the exopolysaccharide component of the matrix causes an increase in osmotic pressure that leads to an inhibition of matrix gene expression. We further show that non-specific changes in osmotic pressure also inhibit matrix gene expression and do so by activating the histidine kinase KinD. KinD, in turn, directs the phosphorylation of the master regulatory protein Spo0A, which at high levels represses matrix gene expression. Sensing a physical cue such as osmotic pressure, in addition to chemical cues, could be a strategy to non-specifically co-ordinate the behaviour of cells in communities composed of many different species.