A Nb2O5/g-C3N4 composite with a controllable loading amount of g-C3N4 nanosheets is successfully prepared by a combination of electrospinning and the double crucible gas-solid reaction method. During the heat treatment process, the precursor molecules of melamine gas are in-situ polymerized on the surface of Nb2O5 nanofibers to form g-C3N4 nanosheets. The Nb2O5 nanofibers ultralong one-dimensional nanostructure can effectively avoid the aggregations of g-C3N4 and form tight heterojunction interfaces. The optimized Nb2O5/g-C3N4 composite material improved the photocatalytic activity for methylene blue degradation, with a rate constant twice that of Nb2O5 nanofibers and 3.8 times that of pure g-C3N4. Using the combination of DFT theoretical calculations and capture experiments, the transfer mechanism of the Nb2O5/g-C3N4 type-II heterojunction is confirmed. It was found that the d orbital of Nb and the p orbital of N were the main active site of the photocatalytic reaction. Meanwhile, the lithium-sulfur (Li-S) battery assembled with NOCN-8 as the host material exhibited a high initial discharge capacity of 900 mAh g−1 at 0.5 C, and its capacity decay rate was less than 0.1% after 500 cycles. It shows that NOCN-8 can effectively adsorb polysulfide and catalyze the conversion reaction of polysulfide. This work provides a novel route for the synthesis of the Nb2O5/g-C3N4 composite, and has great potential in the development of environmental remediation and energy applications.