AbstractFor various 2-Calabi–Yau categories $\mathscr{C}$ C for which the classical stack of objects $\mathfrak{M}$ M has a good moduli space $p\colon \mathfrak{M}\rightarrow \mathcal{M}$ p : M → M , we establish purity of the mixed Hodge module complex $p_{!}\underline{{\mathbb{Q}}}_{{\mathfrak {M}}}$ p ! Q _ M . We do this by using formality in 2CY categories, along with étale neighbourhood theorems for stacks, to prove that the morphism $p$ p is modelled étale-locally by the semisimplification morphism from the stack of modules of a preprojective algebra. Via the integrality theorem in cohomological Donaldson–Thomas theory we then prove purity of $p_{!}\underline{{\mathbb{Q}}}_{{\mathfrak {M}}}$ p ! Q _ M . It follows that the Beilinson–Bernstein–Deligne–Gabber decomposition theorem for the constant sheaf holds for the morphism $p$ p , despite the possibly singular and stacky nature of ${\mathfrak {M}}$ M , and the fact that $p$ p is not proper. We use this to define cuspidal cohomology for ${\mathfrak {M}}$ M , which conjecturally provides a complete space of generators for the BPS algebra associated to $\mathscr{C}$ C . We prove purity of the Borel–Moore homology of the moduli stack $\mathfrak{M}$ M , provided its good moduli space ℳ is projective, or admits a suitable contracting ${\mathbb{C}}^{*}$ C ∗ -action. In particular, when $\mathfrak{M}$ M is the moduli stack of Gieseker semistable sheaves on a K3 surface, this proves a conjecture of Halpern-Leistner. We use these results to moreover prove purity for several stacks of coherent sheaves that do not admit a good moduli space. Without the usual assumption that $r$ r and $d$ d are coprime, we prove that the Borel–Moore homology of the stack of semistable degree $d$ d rank $r$ r Higgs sheaves is pure and carries a perverse filtration with respect to the Hitchin base, generalising the usual perverse filtration for the Hitchin system to the case of singular stacks of Higgs sheaves.