Cyclic dinucleotides (CDNs) are highly versatile signalling molecules that control various important biological processes in bacteria. The best-studied example is cyclic di-GMP (c-di-GMP). Known since the late 1980s, it is now recognized as a near-ubiquitous second messenger that coordinates diverse aspects of bacterial growth and behaviour, including motility, virulence, biofilm formation and cell cycle progression. In this Review, we discuss important new insights that have been gained into the molecular principles of c-di-GMP synthesis and degradation, which are mediated by diguanylate cyclases and c-di-GMP-specific phosphodiesterases, respectively, and the cellular functions that are exerted by c-di-GMP-binding effectors and their diverse targets. Finally, we provide a short overview of the signalling versatility of other CDNs, including c-di-AMP and cGMP-AMP (cGAMP).