Melamine was added to the precursor of TiO2, then TiO2 prepared by hydrothermal, while melamine was modified. Subsequently, a series of Z-scheme TiO2/g-C3N4 heterojunction composites were successfully synthesized by simple calcination. The morphology and structure of samples were characterized by XRD, FT-IR, UV–vis DRS, SEM, TEM, PL and BET. The photocatalytic activity of these samples has been investigated by degradation of Rhodamine B (RhB), and results indicated that photocatalytic activity of the as-prepared samples was greatly influenced by the content of titanium tetrabutoxide in precursors and the hydrothermal time. The degradation rate of TiO2/g-C3N4-1 to RhB was the best, which was 5.05-fold of pure TiO2 (19.61%) and 2.25-fold of bulk g-C3N4 (44.06%), respectively. The trapping experiment results showed that ·O2− and h+ were main active species during degradation of RhB. The photocatalytic activity of the sample did not decrease significantly after 4 cycles. The unique Z-scheme heterojunction between TiO2 and g-C3N4 improved photocatalytic activity of the samples under visible light.