Unipolar barrier structures are used to suppress dark current in photodetectors by blocking majority carriers. Designing unipolar barriers with conventional materials is challenging due to the strict requirements of lattice and band matching. Two-dimensional materials have self-passivated surfaces and tunable band structures, and can thus be used to design unipolar barriers in which lattice mismatch and interface defects are avoided. Here, we show that band-engineered van der Waals heterostructures can be used to build visible and mid-wavelength infrared unipolar barrier photodetectors. Our nBn unipolar barrier photodetectors, which are based on a tungsten disulfide/hexagonal boron nitride/palladium diselenide heterostructure, exhibit a low dark current of 15 pA, a photocurrent of 20 μA and a detectivity of 2.7 × 1012 cm Hz1/2 W−1. Our pBp unipolar barrier photodetectors, which are based on a black phosphorus/molybdenum disulfide/graphene heterostructure, exhibit a room-temperature detectivity of 2.3 × 1010 cm Hz1/2 W−1 in the mid-wavelength infrared region under blackbody radiation. The pBp devices also show a dichroic ratio of 4.9 under blackbody radiation, and a response time of 23 μs under 2 μm laser illumination.