Novel SnO2–x /g-C3N4 heterojunction nanocomposites composed of reduced SnO2–x nanoparticles and exfoliated g-C3N4 nanosheets were prepared by a convenient one-step pyrolysis method. The structural, morphological, and optical properties of the as-prepared nanocomposites were characterized in detail, indicating that the aggregation of g-C3N4 nanosheets was prevented by small, well-dispersed SnO2–x nanoparticles. The ultraviolet–visible spectroscopy absorption bands of the nanocomposites were shifted to a longer wavelength region than those exhibited by pure SnO2 or g-C3N4. The charge transfer and recombination processes occurring in the nanocomposites were investigated using linear scan voltammetry and electrochemical impedance spectroscopy. Under 30-W visible-light-emitting diode irradiation, the heterojunction containing 27.4 wt.% SnO2–x exhibited the highest photocurrent density of 0.0468 mA·cm–2, which is 33.43 and 5.64 times larger than that of pure SnO2 and g-C3N4, respectively. The photocatalytic activity of the heterojunction material was investigated by degrading rhodamine B under irradiation from the same light source. Kinetic study revealed a promising degradation rate constant of 0.0226 min−1 for the heterojunction containing 27.4 wt.% SnO2–x , which is 32.28 and 5.79 times higher than that of pure SnO2 and g-C3N4, respectively. The enhanced photoelectrochemical and photocatalytic performances of the nanocomposite may be due to its appropriate SnO2–x content and the compact structure of the junction between the SnO2–x nanoparticles and the g-C3N4 nanosheets, which inhibits the recombination of photogenerated electrons and holes.