  We compute the complete 3- and 4-dimensional tensor hierarchies, i.e. sets of
p-form fields, with $1\le p\le D$, which realize an off-shell algebra of
bosonic gauge transformations. We show how these tensor hierarchies can be put
on-shell by introducing a set of duality relations, thereby introducing
additional scalars and a metric tensor. These so-called duality hierarchies
encode the equations of motion of the bosonic part of the most general gauged
supergravity theories in those dimensions, including the (projected) scalar
equations of motion. We construct gauge-invariant actions that include all the
fields in the tensor hierarchies. We elucidate the relation between the gauge
transformations of the p-form fields in the action and those of the same fields
in the tensor hierarchy.
