  We present a structural description of finite nilpotent groups of class at
most $2$ using a specified number of subdirect and central products of
$2$-generated such groups. As a corollary, we show that all of these groups are
isomorphic to a subgroup of a Heisenberg group satisfying certain properties.
The motivation for these results is of topological nature as they can be used
to give lower bounds to the nilpotently Jordan property of the birational
automorphism group of varieties and the homeomorphism group of compact
manifolds.
