Abstract We present, for the first time, a Lagrangian multiform for the complete Kadomtsev–Petviashvili hierarchy—a single variational object that generates the whole hierarchy and encapsulates its integrability. By performing a reduction on this Lagrangian multiform, we also obtain Lagrangian multiforms for the Gelfand–Dickey hierarchy of hierarchies, comprising, among others, the Korteweg–de Vries and Boussinesq hierarchies.