  We study the cohomology of $G$-representation varieties and $G$-character
stacks by means of a topological quantum field theory (TQFT). This TQFT is
constructed as the composite of a so-called field theory and the 6-functor
formalism of sheaves on topological stacks. We apply this framework to compute
the cohomology of various $G$-representation varieties and $G$-character stacks
of closed surfaces for $G = \text{SU}(2), \text{SO}(3)$ and $\text{U}(2)$. This
work can be seen as a categorification of earlier work, in which such a TQFT
was constructed on the level of Grothendieck groups to compute the
corresponding Euler characteristics.
