Novel near-infrared pyrimidine-fused pH fluorescent probes were prepared by an unusual barbiturate-mediated debenzoindolation and subsequent heteroannulation. A plausible mechanistic pathway is proposed, and the final structures were further elucidated by 2D-NMR. All new compounds are highly fluorescent in the near-infrared region and possess excellent spectral sensitivities to environmental pH changes.