Polymeric graphitic carbon nitride (g-C3N4) shares a structural similarity to graphene, yet it possesses a distinctive electronic band structure, rendering it promising for photoelectric applications. However, g-C3N4 faces inherent limitations such as inadequate crystalline quality, limited conductivity, and a short lifespan of photogenerated charge carriers, all of which impede the photoelectric conversion efficiency. In this work, we introduce a two-step thermal vapor condensation method for depositing compact, crack-free sulfur-doped g-C3N4 thin films. The doped thin films exhibit reduced interlayer spacing, which leads to improved conductivity and charge transfer capabilities. These processes culminate in the creation of sulfur-doped g-C3N4/GaN thin film heterojunction blue-ultraviolet photodetectors with remarkable photodetection performance, including an ultrahigh on/off ratio of 7.3 × 107 and specific detectivity of 2.06 × 1014 Jones under a low bias of −0.4 V. Moreover, it is found that the n-n heterojunction undergoes a transition from photodiode to photoconduction behavior, attributed to the photoinduced electron trapping effects by sulfur-doped sites, which outcomes a notable gain with the responsivity as high as 581 mA/W. These findings underscore the vast potential of high-quality sulfur-doped g-C3N4 thin films for photoelectric applications.