Infrared photodetectors and cameras have been demonstrated important applications in intelligent society. The current infrared detectors based on III-V/II-VI semiconductors, however, always suffer from complex preparation processes, high cost, and cryogenic operations. Two-dimensional (2D) layered materials with tunable bandgaps and good optoelectronic properties, therefore, show great potential for high-performance infrared photodetection. Furthermore, the tunable carrier polarities in 2D layered materials are the essential requirements for fabrication of functional elements (p-n junctions or inverters). Here, we reported synthesized 2D HfS2(1−x)Te2x single-crystalline materials with highly-tunable carrier polarity (n-type, intrinsic, p-type, or semimetal) for short-wave infrared (SWIR) photodetection. Electrical measurements and density-functional theory calculations show their carrier polarity and bandgaps can be modulated simultaneously by varying chemical compositions. We then demonstrated HfS0.68Te1.32/HfS1.8Te0.2 van der Waals heterojunction photodiodes which exhibited a desired room-temperature specific detectivity of 3.5 × 109 cm Hz1/2 W−1 and fast response time of 78.9/ 95 μs in SWIR regime. Our work provides an alternative strategy for broadband detection using bandgap engineering and tunable carrier polarities in 2D layered materials.