The aim of this paper is to investigate a class of generalised Kadomtsev–Petviashvili (KP) and B-type Kadomtsev–Petviashvili (BKP) equations, which include many important nonlinear evolution equations as its special cases. By applying the fundamental Pfaffian identity, a general Pfaffian formulation is established and all the involved generating functions for Pfaffian entries need to satisfy a system of combined linear partial differential equations. The illustrative examples of the presented Pfaffian solutions are given for the (3$$+$$ + 1)-dimensional generalised KP, Jimbo–Miwa and BKP equations. Moreover, we use the linear superposition principle to generate exponential travelling wave solutions and mixed resonant solutions of the considered equations.