The classical Hochschild--Kostant--Rosenberg (HKR) theorem computes the Hochschild homology and cohomology of smooth commutative algebras. In this paper, we generalise this result to other kinds of algebraic structures. Our main insight is that producing HKR isomorphisms for other types of algebras is directly related to computing quasi-free resolutions in the category of left modules over an operad; we establish that an HKR-type result follows as soon as this resolution is diagonally pure. As examples we obtain a permutative and a pre-Lie HKR theorem for smooth commutative and smooth brace algebras, respectively. We also prove an HKR theorem for operads obtained from a filtered distributive law, which recovers, in particular, all the aspects of the classical HKR theorem. Finally, we show that this property is Koszul dual to the operadic PBW property defined by V. Dotsenko and the second author (1804.06485).