  A topological flux function is introduced to quantify the topology of
magnetic braids: non-zero line-tied magnetic fields whose field lines all
connect between two boundaries. This scalar function is an ideal invariant
defined on a cross-section of the magnetic field, whose integral over the
cross-section yields the relative magnetic helicity. Recognising that the
topological flux function is an action in the Hamiltonian formulation of the
field line equations, a simple formula for its differential is obtained. We use
this to prove that the topological flux function uniquely characterises the
field line mapping and hence the magnetic topology. A simple example is
presented.
