The transition of DNA secondary structure from the B to Z conformation was detected via modulation of the intrinsic near-infrared fluorescence of single-walled carbon nanotubes. A reversible shift in emission energy of DNA-encapsulated nanotubes was found to closely match the thermodynamics of the transition of unbound DNA. A 30-mer oligonucleotide on the nanotube surface behaves as if it were shortened by 1/6 due to the propagation length of the B-Z transition. The system motivates new near-infrared biosensors capable of operation in strongly scattering or absorbing media, and we demonstrate the optical detection of the B-Z transition from localized complexes within live mammalian cells.